Skip to content

Commit ee8ac37

Browse files
committed
Updates the error message alert text
1 parent 67e63db commit ee8ac37

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

jsfmt-sublime.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sublime
22
import sublime_plugin
33
import json
4+
import re
45
from os.path import dirname, realpath, join, splitext
56

67
try:
@@ -57,11 +58,16 @@ def jsfmt(self, data, scope):
5758

5859
return node_bridge(data, BIN_PATH, cdir, [opt, scope, optJSON])
5960
except Exception as e:
60-
msg = '\n\nJSFMT ==>\n%s\n\n' % e
61+
msg = "The formatting failed please check the console for more details."
62+
# Seach for the line number in case of a js error
63+
t = re.search('Error: Line [0-9]+: (.*)', str(e), flags=re.MULTILINE)
64+
if t:
65+
msg += '\n' + t.string[t.start():t.end()]
66+
6167
if settings.get('alert-errors', True):
6268
sublime.error_message(msg)
63-
else:
64-
print(msg)
69+
70+
print('\n\nJSFMT ==>\n%s\n\n' % e)
6571

6672
def has_selection(self):
6773
for sel in self.view.sel():

0 commit comments

Comments
 (0)