@@ -18,30 +18,39 @@ const attachFormat = () => {
1818 const semicolonNewline = document . getElementById ( 'semicolonNewline' ) ;
1919
2020 function format ( ) {
21- console . time ( 'formatting' ) ;
22- const config = {
23- language : language . options [ language . selectedIndex ] . value ,
24- uppercase : uppercase . checked ,
25- keywordPosition : keywordPosition . options [ keywordPosition . selectedIndex ] . value ,
26- breakBeforeBooleanOperator : breakBeforeBooleanOperator . checked ,
27- aliasAs : aliasAs . checked ,
28- newline : {
29- mode : newline . options [ newline . selectedIndex ] . value ,
30- itemCount : itemCount . value ,
31- } ,
32- tabulateAlias : tabulateAlias . checked ,
33- commaPosition : commaPosition . options [ commaPosition . selectedIndex ] . value ,
34- parenOptions : {
35- openParenNewline : openParenNewline . checked ,
36- closeParenNewline : closeParenNewline . checked ,
37- } ,
38- lineWidth : lineWidth . value ,
39- lineBetweenQueries : lineBetweenQueries . value ,
40- denseOperators : denseOperators . checked ,
41- semicolonNewline : semicolonNewline . checked ,
42- } ;
43- output . value = prettierSql . format ( input . value , config ) ;
44- console . timeEnd ( 'formatting' ) ;
21+ try {
22+ console . time ( 'formatting' ) ;
23+ const config = {
24+ language : language . options [ language . selectedIndex ] . value ,
25+ uppercase : uppercase . checked ,
26+ keywordPosition : keywordPosition . options [ keywordPosition . selectedIndex ] . value ,
27+ breakBeforeBooleanOperator : breakBeforeBooleanOperator . checked ,
28+ aliasAs : aliasAs . options [ aliasAs . selectedIndex ] . value ,
29+ newline : {
30+ mode : newline . options [ newline . selectedIndex ] . value ,
31+ itemCount : itemCount . value ,
32+ } ,
33+ tabulateAlias : tabulateAlias . checked ,
34+ commaPosition : commaPosition . options [ commaPosition . selectedIndex ] . value ,
35+ parenOptions : {
36+ openParenNewline : openParenNewline . checked ,
37+ closeParenNewline : closeParenNewline . checked ,
38+ } ,
39+ lineWidth : lineWidth . value ,
40+ lineBetweenQueries : lineBetweenQueries . value ,
41+ denseOperators : denseOperators . checked ,
42+ semicolonNewline : semicolonNewline . checked ,
43+ } ;
44+ output . value = prettierSql . format ( input . value , config ) ;
45+ console . timeEnd ( 'formatting' ) ;
46+ } catch ( e ) {
47+ output . value = `
48+ An Error Occurred, please report this at:
49+ https://github.com/inferrinizzard/prettier-sql/issues\n
50+ Stack Trace:
51+ ${ e . stack . toString ( ) }
52+ ` ;
53+ }
4554 }
4655
4756 input . addEventListener ( 'input' , format ) ;
0 commit comments