mirror of https://git.tuxpa.in/a/code-server.git
Include details if any in JSON requests
This commit is contained in:
parent
58bd7008b4
commit
c67d31580f
|
@ -9,7 +9,7 @@ export enum HttpCode {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HttpError extends Error {
|
export class HttpError extends Error {
|
||||||
public constructor(message: string, public readonly code: number) {
|
public constructor(message: string, public readonly code: number, public readonly details?: object) {
|
||||||
super(message)
|
super(message)
|
||||||
this.name = this.constructor.name
|
this.name = this.constructor.name
|
||||||
}
|
}
|
||||||
|
|
|
@ -667,8 +667,10 @@ export class HttpServer {
|
||||||
if (request.headers["content-type"] === "application/json") {
|
if (request.headers["content-type"] === "application/json") {
|
||||||
write({
|
write({
|
||||||
code,
|
code,
|
||||||
|
mime: "application/json",
|
||||||
content: {
|
content: {
|
||||||
error: e.message,
|
error: e.message,
|
||||||
|
...(e.details || {}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue