Skip to content

Commit

Permalink
Improve error message handling and mostly actually show them in the f…
Browse files Browse the repository at this point in the history
…irst place
  • Loading branch information
phil294 committed Feb 23, 2024
1 parent d50729e commit a9e9abd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/extension.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports.activate = (###* @type vscode.ExtensionContext ### context) =>
try
resp.data = await func()
catch e
resp.error = e
resp.error = "Internal extension backend error: #{if typeof e == 'string' then e else e.message}"
post_message resp
switch message.type
when 'request'
Expand Down
4 changes: 3 additions & 1 deletion src/git.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ module.exports.get_git = (EXT_ID, log, { on_repo_external_state_change, on_repo_
if not repo and repo_index > 0
repo_index = 0
repo = api.repositories[repo_index]
throw 'No repository found' if not repo
throw "No repository found for repo_index #{repo_index}" if not repo
if ! repo
throw "No repository selected"
cwd = repo.rootUri.fsPath
{ stdout, stderr: _ } = await exec 'git ' + args,
cwd: cwd
Expand Down
3 changes: 2 additions & 1 deletion web/src/bridge.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export exchange_message = (###* @type string ### command, ###* @type any ### dat
response_handlers[id] = (data) =>
ok data
console.info "exchange_message", command, data # , resp
if resp.error then throw resp.error
if resp.error
throw new Error(JSON.stringify({ error_response: resp.error, request }))
resp.data

###* @return {Promise<string>} ###
Expand Down
3 changes: 2 additions & 1 deletion web/src/vue-app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import '@vscode/codicons/dist/codicon.css'

console_error = console.error
handle_error = (###* @type {any} ### e) =>
console_error e
console_error e, new Error().stack
console.trace()
debugger
show_error_message "git log --graph extension encountered an unexpected error. Sorry! Error summary: " + (e.message or e.msg or e.data or e.body or e.stack or try JSON.stringify(e) or e.toString?()) + ". For details, see VSCode developer console. Please consider reporting this error."
window.onerror = handle_error
Expand Down

0 comments on commit a9e9abd

Please sign in to comment.