Add error code getter to FileSystemError #90517#90586
Add error code getter to FileSystemError #90517#90586jrieken merged 1 commit intomicrosoft:masterfrom iliazeus:90517-file-system-error-code
Conversation
|
👎 this duplicates information that's already available in the ctor. To know what kind of error happened you can use an instanceof-check or the ctor-name if you like. |
It seems that there's no information in the prototype chain about the specific kind of filesystem error (file not found/no permissions/etc.). https://github.com/microsoft/vscode/blob/master/src/vs/workbench/api/common/extHostTypes.ts#L2305 Are you suggesting subclassing |
Oh, I am sorry. I thought we already had that... Now your PR makes much more sense but I would keep it more minimal tbh. How about using the |
|
https://github.com/microsoft/vscode/blob/master/src/vs/platform/files/common/files.ts#L346 In an extension, I could just parse |
|
What I don't like that those names - they are internal and don't make much sense in the API, like the error code for export class FileSystemError extends Error {
//...
/**
* A code that identifies this error. The value is equal to
* the (class) name of the error, e.g `FileNotFound`.
*/
readonly code: string
} |
|
I've also found some I've changed them to appropriate factory function calls, so the |
| }; | ||
| } | ||
| return Promise.reject(new FileSystemError(resource, FileSystemProviderErrorCode.FileNotFound)); | ||
| return Promise.reject(FileSystemError.FileNotFound(resource)); |
There was a problem hiding this comment.
fyi @sandy081 but also 🙅♂ no good usage of API types inside the core. This shouldn't be like that
There was a problem hiding this comment.
Sorry. Could be a copy/paste issue. Fixed and used proper fs errors.
|
Thanks @iliazeus. I'll merge and drive this as api-proposal to finalization |
This PR fixes #90517
The only way I found in the current source to extract the error code from a
FileSystemErroris through callingtoFileSystemProviderErrorCode(). This PR exposes that ability to extensions through a getter on classFileSystemError.