diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index e8d2a83f063bf1ef48212c241410fe99cc1b406d..a32ee446924210519df6d1b59492a7711a8aa105 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -100,16 +100,44 @@ declare module 'vscode' { //#region Joh: file system provider (new) /** + * A type that filesystem providers should use to signal errors. * + * This class has factory methods for common error-cases, like `EntryNotFound` when + * a file or folder doesn't exist. Use them like so `throw vscode.FileSystemError.EntryNotFound(uri);` */ export class FileSystemError extends Error { - static EntryExists(message?: string): FileSystemError; - static EntryNotFound(message?: string): FileSystemError; - static EntryNotADirectory(message?: string): FileSystemError; - static EntryIsADirectory(message?: string): FileSystemError; + /** + * Create an error to signal that a file or folder wasn't found. + * @param messageOrUri Message or uri. + */ + static EntryNotFound(messageOrUri?: string | Uri): FileSystemError; + + /** + * Create an error to signal that a file or folder already exists, e.g. when + * creating but not overwriting a file. + * @param messageOrUri Message or uri. + */ + static EntryExists(messageOrUri?: string | Uri): FileSystemError; - constructor(message?: string); + /** + * Create an error to signal that a file is not a folder. + * @param messageOrUri Message or uri. + */ + static EntryNotADirectory(messageOrUri?: string | Uri): FileSystemError; + + /** + * Create an error to signal that a file is a folder. + * @param messageOrUri Message or uri. + */ + static EntryIsADirectory(messageOrUri?: string | Uri): FileSystemError; + + /** + * Creates a new filesystem error. + * + * @param messageOrUri Message or uri. + */ + constructor(messageOrUri?: string | Uri); } export enum FileChangeType2 { @@ -122,6 +150,10 @@ declare module 'vscode' { * The event filesystem providers must use to signal a file change. */ export interface FileChangeEvent { + + /** + * + */ type: FileChangeType2; /** @@ -131,7 +163,7 @@ declare module 'vscode' { } /** - * Metadata about a file. + * The `FileStat`-type represents metadata about a file. */ export interface FileStat2 { /** @@ -161,7 +193,7 @@ declare module 'vscode' { } /** - * + * Commonly used options when reading, writing, or stat'ing files or folders. */ export interface FileOptions { diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index f75c83dbe184be06234f7beb8ac26cad424ae987..491bbf87129bd4be89854484dcff1120f26c63ef 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -1834,26 +1834,26 @@ export enum FileType { export class FileSystemError extends Error { - static EntryExists(message?: string): FileSystemError { - return new FileSystemError(message, 'EntryExists', FileSystemError.EntryExists); + static EntryExists(messageOrUri?: string | URI): FileSystemError { + return new FileSystemError(messageOrUri, 'EntryExists', FileSystemError.EntryExists); } - static EntryNotFound(message?: string): FileSystemError { - return new FileSystemError(message, 'EntryNotFound', FileSystemError.EntryNotFound); + static EntryNotFound(messageOrUri?: string | URI): FileSystemError { + return new FileSystemError(messageOrUri, 'EntryNotFound', FileSystemError.EntryNotFound); } - static EntryNotADirectory(message?: string): FileSystemError { - return new FileSystemError(message, 'EntryNotADirectory', FileSystemError.EntryNotADirectory); + static EntryNotADirectory(messageOrUri?: string | URI): FileSystemError { + return new FileSystemError(messageOrUri, 'EntryNotADirectory', FileSystemError.EntryNotADirectory); } - static EntryIsADirectory(message?: string): FileSystemError { - return new FileSystemError(message, 'EntryIsADirectory', FileSystemError.EntryIsADirectory); + static EntryIsADirectory(messageOrUri?: string | URI): FileSystemError { + return new FileSystemError(messageOrUri, 'EntryIsADirectory', FileSystemError.EntryIsADirectory); } - constructor(message?: string, code?: string, hide?: Function) { - super(message); + constructor(uriOrMessage?: string | URI, code?: string, terminator?: Function) { + super(URI.isUri(uriOrMessage) ? uriOrMessage.toString(true) : uriOrMessage); this.name = code ? `${code} (FileSystemError)` : `FileSystemError`; - if (typeof Error.captureStackTrace === 'function' && typeof hide === 'function') { + if (typeof Error.captureStackTrace === 'function' && typeof terminator === 'function') { // nice stack traces - Error.captureStackTrace(this, hide); + Error.captureStackTrace(this, terminator); } } }