From 03a1c5a84e21e325f2e724c6a2d39e4e7ad44da6 Mon Sep 17 00:00:00 2001 From: Pierre GIRAUD Date: Wed, 13 Nov 2024 16:43:15 +0100 Subject: [PATCH] Don't fail on SQL format errors --- powa/static/js/utils/sql.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/powa/static/js/utils/sql.js b/powa/static/js/utils/sql.js index be74915d..9d520773 100644 --- a/powa/static/js/utils/sql.js +++ b/powa/static/js/utils/sql.js @@ -6,6 +6,11 @@ import { formatDialect, postgresql } from "sql-formatter"; hljs.registerLanguage("sql", pgsql); export function formatSql(value) { - value = formatDialect(value, { dialect: postgresql }); - return hljs.highlightAuto(value, ["sql"]).value; + try { + value = formatDialect(value, { dialect: postgresql }); + value = hljs.highlightAuto(value, ["sql"]).value; + } catch (error) { + console.error("Could not highlight SQL:", value); + } + return value; }