Skip to content

Commit

Permalink
Updates the error message alert text
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-vlc committed Oct 31, 2014
1 parent 67e63db commit ee8ac37
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions jsfmt-sublime.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sublime
import sublime_plugin
import json
import re
from os.path import dirname, realpath, join, splitext

try:
Expand Down Expand Up @@ -57,11 +58,16 @@ def jsfmt(self, data, scope):

return node_bridge(data, BIN_PATH, cdir, [opt, scope, optJSON])
except Exception as e:
msg = '\n\nJSFMT ==>\n%s\n\n' % e
msg = "The formatting failed please check the console for more details."
# Seach for the line number in case of a js error
t = re.search('Error: Line [0-9]+: (.*)', str(e), flags=re.MULTILINE)
if t:
msg += '\n' + t.string[t.start():t.end()]

if settings.get('alert-errors', True):
sublime.error_message(msg)
else:
print(msg)

print('\n\nJSFMT ==>\n%s\n\n' % e)

def has_selection(self):
for sel in self.view.sel():
Expand Down

0 comments on commit ee8ac37

Please sign in to comment.