Skip to content

Commit a1d3f91

Browse files
committed
Add network errors.
1 parent 01d2b3e commit a1d3f91

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/vs/server/common/net.ts

+12
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,15 @@ export const ICON_SIZES = [192, 512];
4040
export function getPathPrefix(pathname: string) {
4141
return posix.join(posix.dirname(pathname), '/');
4242
}
43+
44+
class HTTPError extends Error {
45+
constructor (message: string, public readonly code: number) {
46+
super(message);
47+
}
48+
}
49+
50+
export class HTTPNotFoundError extends HTTPError {
51+
constructor (message: string) {
52+
super(message, 404);
53+
}
54+
}

src/vs/server/webClientServer.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
2626
// eslint-disable-next-line code-import-patterns
2727
import type { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
2828
import { editorBackground, editorForeground } from 'vs/platform/theme/common/colorRegistry';
29-
import { ClientTheme, getPathPrefix, WebManifest } from 'vs/server/common/net';
29+
import { ClientTheme, getPathPrefix, HTTPNotFoundError, WebManifest } from 'vs/server/common/net';
3030
import { IServerThemeService } from 'vs/server/serverThemeService';
3131
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
3232

@@ -130,8 +130,7 @@ export class WebClientServer {
130130
return this._handleRoot(req, res, parsedUrl);
131131
}
132132

133-
const message = `"${parsedUrl.pathname}" not found.`;
134-
const error = new Error(message);
133+
const error = new HTTPNotFoundError(`"${parsedUrl.pathname}" not found.`);
135134
req.emit('error', error);
136135
return;
137136
} catch (error) {

0 commit comments

Comments
 (0)