use Object#setPrototypeOf, #49386

This commit is contained in:
Johannes Rieken
2018-05-08 12:50:23 +02:00
parent a411c2f4e6
commit d606038e03
2 changed files with 12 additions and 0 deletions

View File

@@ -1890,6 +1890,12 @@ export class FileSystemError extends Error {
super(URI.isUri(uriOrMessage) ? uriOrMessage.toString(true) : uriOrMessage);
this.name = code ? `${code} (FileSystemError)` : `FileSystemError`;
// workaround when extending builtin objects and when compiling to ES5, see:
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
if (typeof (<any>Object).setPrototypeOf === 'function') {
(<any>Object).setPrototypeOf(this, FileSystemError.prototype);
}
if (typeof Error.captureStackTrace === 'function' && typeof terminator === 'function') {
// nice stack traces
Error.captureStackTrace(this, terminator);