Skip to content
This repository was archived by the owner on Oct 2, 2021. It is now read-only.

Change the way error message is surfaced up to the UI. #303

Merged
merged 1 commit into from
Mar 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/chrome/chromeDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,22 @@ export class ChromeDebugSession extends LoggingDebugSession implements IObservab
return;
}

const errMsg = isChromeError(error) ?
const errUserMsg = isChromeError(error) ?
error.message + ': ' + error.data :
(error.stack || error.message);
(error.message || error.stack);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error.message is more user friendly than error.stack(which is a stack for the DA itself, not the user code). So when reporting an error to the UI, we let error.message take priority.

The original message is put to errDiagnosticMsg, and emitted by the Output event. So we are not losing anything with this code change. If user is interested, s/he can still find the callstack in the output pane.


logger.error(`Error processing "${requestType}": ${errMsg}`);
const errDiagnosticMsg = isChromeError(error) ?
errUserMsg : (error.stack || error.message);

logger.error(`Error processing "${requestType}": ${errDiagnosticMsg}`);

// These errors show up in the message bar at the top (or nowhere), sometimes not obvious that they
// come from the adapter, so add extensionName
this.sendErrorResponse(
response,
1104,
'[{_extensionName}] Error processing "{_requestType}": {_stack}',
{ _extensionName: this._extensionName, _requestType: requestType, _stack: errMsg },
{ _extensionName: this._extensionName, _requestType: requestType, _stack: errUserMsg },
ErrorDestination.Telemetry);
}

Expand Down