mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
files - errors from main side are not properly deserialized (#169389)
This commit is contained in:
parent
a56c38c075
commit
1521421ee0
|
@ -13,7 +13,7 @@ import { newWriteableStream, ReadableStreamEventPayload, ReadableStreamEvents }
|
|||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { createFileSystemProviderError, IFileAtomicReadOptions, FileChangeType, IFileDeleteOptions, IFileOpenOptions, IFileOverwriteOptions, IFileReadStreamOptions, FileSystemProviderCapabilities, FileSystemProviderErrorCode, FileType, IFileWriteOptions, IFileChange, IFileSystemProviderWithFileAtomicReadCapability, IFileSystemProviderWithFileCloneCapability, IFileSystemProviderWithFileFolderCopyCapability, IFileSystemProviderWithFileReadStreamCapability, IFileSystemProviderWithFileReadWriteCapability, IFileSystemProviderWithOpenReadWriteCloseCapability, IStat, IWatchOptions } from 'vs/platform/files/common/files';
|
||||
import { createFileSystemProviderError, IFileAtomicReadOptions, FileChangeType, IFileDeleteOptions, IFileOpenOptions, IFileOverwriteOptions, IFileReadStreamOptions, FileSystemProviderCapabilities, FileSystemProviderErrorCode, FileType, IFileWriteOptions, IFileChange, IFileSystemProviderWithFileAtomicReadCapability, IFileSystemProviderWithFileCloneCapability, IFileSystemProviderWithFileFolderCopyCapability, IFileSystemProviderWithFileReadStreamCapability, IFileSystemProviderWithFileReadWriteCapability, IFileSystemProviderWithOpenReadWriteCloseCapability, IStat, IWatchOptions, IFileSystemProviderError } from 'vs/platform/files/common/files';
|
||||
|
||||
export const LOCAL_FILE_SYSTEM_CHANNEL_NAME = 'localFilesystem';
|
||||
|
||||
|
@ -105,14 +105,20 @@ export class DiskFileSystemProviderClient extends Disposable implements
|
|||
if (dataOrErrorOrEnd === 'end') {
|
||||
stream.end();
|
||||
} else {
|
||||
let error: Error;
|
||||
|
||||
// Since we receive data through a IPC channel, it is likely
|
||||
// that the error was not serialized, or only partially. To
|
||||
// ensure our API use is correct, we convert the data to an
|
||||
// error here to forward it properly.
|
||||
let error = dataOrErrorOrEnd;
|
||||
if (!(error instanceof Error)) {
|
||||
error = createFileSystemProviderError(toErrorMessage(error), FileSystemProviderErrorCode.Unknown);
|
||||
// Take Error as is if type matches
|
||||
if (dataOrErrorOrEnd instanceof Error) {
|
||||
error = dataOrErrorOrEnd;
|
||||
}
|
||||
|
||||
// Otherwise, try to deserialize into an error.
|
||||
// Since we communicate via IPC, we cannot be sure
|
||||
// that Error objects are properly serialized.
|
||||
else {
|
||||
const errorCandidate = dataOrErrorOrEnd as IFileSystemProviderError;
|
||||
|
||||
error = createFileSystemProviderError(errorCandidate.message ?? toErrorMessage(errorCandidate), errorCandidate.code ?? FileSystemProviderErrorCode.Unknown);
|
||||
}
|
||||
|
||||
stream.error(error);
|
||||
|
|
|
@ -597,7 +597,12 @@ export enum FileSystemProviderErrorCode {
|
|||
Unknown = 'Unknown'
|
||||
}
|
||||
|
||||
export class FileSystemProviderError extends Error {
|
||||
export interface IFileSystemProviderError extends Error {
|
||||
readonly name: string;
|
||||
readonly code: FileSystemProviderErrorCode;
|
||||
}
|
||||
|
||||
export class FileSystemProviderError extends Error implements IFileSystemProviderError {
|
||||
|
||||
constructor(message: string, readonly code: FileSystemProviderErrorCode) {
|
||||
super(message);
|
||||
|
|
Loading…
Reference in a new issue