Skip to content

Commit

Permalink
properly spec error data, #32766
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Aug 18, 2017
1 parent 69c9ede commit dc69d8b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/vs/base/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ export function onUnexpectedPromiseError<T>(promise: TPromise<T>): TPromise<T |
return promise.then(null, onUnexpectedError);
}

export interface SerializedError {
readonly $isError: true;
readonly name: string;
readonly message: string;
readonly stack: string;
}

export function transformErrorForSerialization(error: Error): SerializedError;
export function transformErrorForSerialization(error: any): any;
export function transformErrorForSerialization(error: any): any {
if (error instanceof Error) {
let { name, message } = error;
Expand Down
9 changes: 8 additions & 1 deletion src/vs/workbench/api/electron-browser/mainThreadErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ export class MainThreadErrors implements MainThreadErrorsShape {
public dispose(): void {
}

public $onUnexpectedExtHostError(err: any): void {
public $onUnexpectedExtHostError(err: any | errors.SerializedError): void {
if (err.$isError) {
const { name, message, stack } = err;
err = new Error();
err.name = name;
err.message = message;
err.stack = stack;
}
errors.onUnexpectedError(err);
}
}

0 comments on commit dc69d8b

Please sign in to comment.