Skip to content

Commit 9d10006

Browse files
Error handling for message parsing
1 parent 5bbf3f1 commit 9d10006

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/autocomplete/lib/autocomplete-handler.coffee

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ class AutocompleteHandler
3939
action = (s) =>
4040
split = s.split /\r\n|\r|\n/
4141
if(split.length > 1)
42-
obj = JSON.parse split[1]
43-
if(obj.Kind == "errors")
44-
atom.emit "FSharp.Atom:Highlight", obj.Data
42+
try
43+
obj = JSON.parse split[1]
44+
if(obj.Kind == "errors")
45+
atom.emit "FSharp.Atom:Highlight", obj.Data
46+
catch error
47+
console.log(error)
4548
callback s
4649

4750
@parse(path,text, action)

src/autocomplete/lib/autocomplete-provider.coffee

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ module.exports =
1414
msplit = s.split("\n")
1515
if msplit.length > 1
1616
msg = msplit[1]
17-
obj = JSON.parse(msg)
18-
prefix = options.prefix
19-
if(prefix == '.' or prefix == '=')
20-
prefix = ''
21-
if obj.Kind == "completion"
22-
result = ({text: item, replacementPrefix: prefix } for item in obj.Data when item.contains(prefix))
23-
resolve(result)
24-
else
17+
try
18+
obj = JSON.parse(msg)
19+
prefix = options.prefix
20+
if(prefix == '.' or prefix == '=')
21+
prefix = ''
22+
if obj.Kind == "completion"
23+
result = ({text: item, replacementPrefix: prefix } for item in obj.Data when item.contains(prefix))
24+
resolve(result)
25+
else
26+
resolve([])
27+
catch error
28+
console.log(error)
2529
resolve([])
2630
else
2731
resolve([])

0 commit comments

Comments
 (0)