mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
Add more specific error for TS web server (#187752)
This should help us better understand why the access failed
This commit is contained in:
@@ -76,6 +76,15 @@ function toTsWatcherKind(event: 'create' | 'change' | 'delete') {
|
||||
throw new Error(`Unknown event: ${event}`);
|
||||
}
|
||||
|
||||
class AccessOutsideOfRootError extends Error {
|
||||
constructor(
|
||||
public readonly filepath: string,
|
||||
public readonly projectRootPaths: readonly string[]
|
||||
) {
|
||||
super(`Could not read file outside of project root ${filepath}`);
|
||||
}
|
||||
}
|
||||
|
||||
type ServerHostWithImport = ts.server.ServerHost & { importPlugin(root: string, moduleName: string): Promise<ts.server.ModuleImportResult> };
|
||||
|
||||
function createServerHost(extensionUri: URI, logger: ts.server.Logger, apiClient: ApiClient | undefined, args: string[], fsWatcher: MessagePort): ServerHostWithImport {
|
||||
@@ -455,7 +464,7 @@ function createServerHost(extensionUri: URI, logger: ts.server.Logger, apiClient
|
||||
}
|
||||
|
||||
if (allowRead === 'block') {
|
||||
throw new Error(`Could not read file outside of project root ${filepath}`);
|
||||
throw new AccessOutsideOfRootError(filepath, Array.from(projectRootPaths.keys()));
|
||||
}
|
||||
|
||||
return uri;
|
||||
|
||||
Reference in New Issue
Block a user