Skip to content

Commit d4352fd

Browse files
committed
handle promise rejections better
1 parent a77140c commit d4352fd

File tree

10 files changed

+87
-37
lines changed

10 files changed

+87
-37
lines changed

lib/connection/process/remote.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function get (path, args) {
1717
return lock((release) => {
1818
let p = get_(path, args)
1919
release(p.then(({socket}) => socket))
20+
p.catch(() => release())
2021
return p
2122
})
2223
}

lib/runtime/completions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class AutoCompleteProvider {
112112
completion.description = ' '
113113
}
114114
return completion
115+
}).catch(err => {
116+
console.log(err)
115117
})
116118
return Promise.race([completionWithDetail, this.sleep()])
117119
}

lib/runtime/console.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ function newTerminal (cwd) {
185185
term.setDefaultLocation(atom.config.get('julia-client.uiOptions.layouts.terminal.defaultLocation'))
186186
term.open({
187187
split: atom.config.get('julia-client.uiOptions.layouts.terminal.split')
188-
}).then(() => term.show())
188+
}).then(() => term.show()).catch(err => {
189+
console.log(err)
190+
})
189191
}).catch(() => {})
190192
}
191193

@@ -334,14 +336,16 @@ function shellPty (cwd) {
334336
cwd = paths.home()
335337
}
336338
const env = customEnv()
339+
const pty = pty.spawn(atom.config.get("julia-client.consoleOptions.shell"), [], {
340+
cols: 100,
341+
rows: 30,
342+
cwd: cwd,
343+
env: env,
344+
useConpty: true,
345+
handleFlowControl: true
346+
})
337347
resolve({
338-
pty: pty.fork(atom.config.get("julia-client.consoleOptions.shell"), [], {
339-
cols: 100,
340-
rows: 30,
341-
cwd: cwd,
342-
env: env,
343-
useConpty: true
344-
}),
348+
pty: pty,
345349
cwd: cwd})
346350
} else {
347351
reject()

lib/runtime/debugger.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ export function debugFile(shouldStep, el) {
225225
const data = { path, code, row: 1, column: 1 }
226226
getmodule(data).then(mod => {
227227
debugfile(modules.current(mod), code, path, shouldStep)
228+
}).catch(err => {
229+
console.log(err)
228230
})
229231
} catch (err) {
230232
atom.notifications.addError('Error happened', {

lib/runtime/evaluation.coffee

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,21 @@ module.exports =
8787
code: code
8888
row: 1
8989
column: 1
90-
getmodule(data).then (mod) =>
91-
evalall({
92-
path: path
93-
module: modules.current mod
94-
code: code
95-
}).then (result) ->
96-
notifications.show "Evaluation Finished"
97-
workspace.update()
90+
getmodule(data)
91+
.then (mod) =>
92+
evalall({
93+
path: path
94+
module: modules.current mod
95+
code: code
96+
})
97+
.then (result) ->
98+
notifications.show "Evaluation Finished"
99+
workspace.update()
100+
.catch (err) =>
101+
console.log(err)
102+
.catch (err) =>
103+
console.log(err)
104+
98105
catch error
99106
atom.notifications.addError 'Error happened',
100107
detail: error
@@ -110,9 +117,12 @@ module.exports =
110117
path: edpath
111118
module: module
112119
code: code
113-
}).then (result) ->
114-
notifications.show "Evaluation Finished"
115-
workspace.update()
120+
})
121+
.then (result) ->
122+
notifications.show "Evaluation Finished"
123+
workspace.update()
124+
.catch (err) =>
125+
console.log(err)
116126

117127
toggleDocs: () ->
118128
{ editor, mod, edpath } = @_currentContext()
@@ -123,18 +133,21 @@ module.exports =
123133
word = editor.getTextInBufferRange(range)
124134

125135
return unless words.isValidWordToInspect(word)
126-
searchDoc({word: word, mod: mod}).then (result) =>
127-
if result.error then return
128-
v = views.render result
129-
processLinks(v.getElementsByTagName('a'))
130-
if atom.config.get('julia-client.uiOptions.docsDisplayMode') == 'inline'
131-
d = new @ink.InlineDoc editor, range,
132-
content: v
133-
highlight: true
134-
d.view.classList.add 'julia'
135-
else
136-
docpane.ensureVisible()
137-
docpane.showDocument(v, [])
136+
searchDoc({word: word, mod: mod})
137+
.then (result) =>
138+
if result.error then return
139+
v = views.render result
140+
processLinks(v.getElementsByTagName('a'))
141+
if atom.config.get('julia-client.uiOptions.docsDisplayMode') == 'inline'
142+
d = new @ink.InlineDoc editor, range,
143+
content: v
144+
highlight: true
145+
d.view.classList.add 'julia'
146+
else
147+
docpane.ensureVisible()
148+
docpane.showDocument(v, [])
149+
.catch (err) =>
150+
console.log(err)
138151

139152
# Working Directory
140153

@@ -177,9 +190,12 @@ module.exports =
177190
else if dirs.length == 1
178191
@_cd dirs[0]
179192
else
180-
selector.show(dirs).then (dir) =>
181-
return unless dir?
182-
@_cd dir
193+
selector.show(dirs)
194+
.then (dir) =>
195+
return unless dir?
196+
@_cd dir
197+
.catch (err) =>
198+
console.log(err)
183199

184200
cdHome: ->
185201
@_cd paths.home()

lib/runtime/formatter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ function formatEditorTextInRange (editor, range, text) {
6060
})
6161
}
6262
}
63+
}).catch(err => {
64+
console.log(err)
6365
}).finally(() => {
6466
marker.destroy()
6567
})
@@ -92,7 +94,11 @@ export function activate() {
9294
edWatch.delete(ed)
9395
ed.save().then(() => {
9496
edWatch.add(ed)
97+
}).catch(err => {
98+
console.log(err)
9599
})
100+
}).catch(err => {
101+
console.log(err)
96102
})
97103
}
98104
}

lib/runtime/goto.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class Goto {
120120
this.ink.goto.goto(results, {
121121
pending: atom.config.get('core.allowPendingPaneItems')
122122
})
123+
}).catch(err => {
124+
console.log(err)
123125
})
124126
}
125127

@@ -196,6 +198,8 @@ class Goto {
196198
}, 5)
197199
}
198200
})
201+
}).catch(err => {
202+
console.log(err)
199203
})
200204
})
201205
}

lib/runtime/modules.coffee

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ module.exports =
6464
else if @lastEditorModule?
6565
modules.unshift @follow
6666
modules
67+
module.catch (err) =>
68+
console.log err
6769
selector.show(modules, active: active).then (mod) =>
6870
return unless mod?
6971
if mod is @autodetect
@@ -84,8 +86,12 @@ module.exports =
8486
@updateForEditor item
8587
else
8688
mod = item.juliaModule or 'Main'
87-
ismodule(mod).then (ismod) =>
88-
@setCurrent main: mod, inactive: !ismod
89+
m = ismodule(mod)
90+
m
91+
.then (ismod) =>
92+
@setCurrent main: mod, inactive: !ismod
93+
.catch (err) =>
94+
console.log err
8995

9096
updateForEditor: (editor) ->
9197
@setCurrent main: editor.juliaModule or 'Main', true
@@ -105,7 +111,8 @@ module.exports =
105111
code: ed.getText()
106112
row: row+1, column: column+1
107113
module: ed.juliaModule
108-
getmodule(data)
114+
getmodule(data).catch (err) =>
115+
console.log err
109116

110117
setEditorModule: (ed) ->
111118
modulePromise = @getEditorModule ed

lib/runtime/outline.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export function activate (ink) {
4646
edSubs.add(ed.onDidStopChanging(() => {
4747
updateEditor(ed).then(outlineItems => {
4848
outline = handleOutline(ed, edSubs, outlineItems)
49+
}).catch(err => {
50+
console.log(err);
4951
})
5052
}))
5153

@@ -64,6 +66,8 @@ export function activate (ink) {
6466
updateSymbols: false
6567
}).then(outlineItems => {
6668
outline = handleOutline(ed, edSubs, outlineItems)
69+
}).catch(err => {
70+
console.log(err);
6771
})
6872
}, 300)))
6973
}

lib/runtime/urihandler.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export default function handleURI (parsedURI) {
2222
docpane.processLinks(view.getElementsByTagName('a'))
2323
docpane.ensureVisible()
2424
docpane.showDocument(view, [])
25+
}).catch(err => {
26+
console.log(err)
2527
})
2628
} else if (query.moduleinfo){ // show module info
2729
const { mod } = query
@@ -32,6 +34,8 @@ export default function handleURI (parsedURI) {
3234
const view = views.render(doc)
3335
docpane.ensureVisible()
3436
docpane.showDocument(view, items)
37+
}).catch(err => {
38+
console.log(err)
3539
})
3640
}
3741
}

0 commit comments

Comments
 (0)