back to FileError, #47475

This commit is contained in:
Johannes Rieken
2018-04-19 11:40:55 +02:00
parent 57a92cb312
commit 3500eb8731
6 changed files with 73 additions and 51 deletions

View File

@@ -713,7 +713,7 @@ export function createApiFactory(
FileChangeType2: extHostTypes.FileChangeType2,
FileType2: extHostTypes.FileType2,
FileOpenFlags: files.FileOpenFlags,
FileError: files.FileError,
FileError: extHostTypes.FileError,
FoldingRange: extHostTypes.FoldingRange,
FoldingRangeKind: extHostTypes.FoldingRangeKind
};

View File

@@ -1838,6 +1838,32 @@ export enum FileType2 {
SymbolicLink = 4,
}
export class FileError extends Error {
static EntryExists(message?: string): FileError {
return new FileError(message, 'EntryExists', FileError.EntryExists);
}
static EntryNotFound(message?: string): FileError {
return new FileError(message, 'EntryNotFound', FileError.EntryNotFound);
}
static EntryNotADirectory(message?: string): FileError {
return new FileError(message, 'EntryNotADirectory', FileError.EntryNotADirectory);
}
static EntryIsADirectory(message?: string): FileError {
return new FileError(message, 'EntryIsADirectory', FileError.EntryIsADirectory);
}
constructor(message?: string, code?: string, hide?: Function) {
super(message);
this.name = code ? `FileError/${code}` : `FileError`;
if (typeof Error.captureStackTrace === 'function' && typeof hide === 'function') {
// nice stack traces
Error.captureStackTrace(this, hide);
}
}
}
//#endregion
//#region folding api