Archived
1
0

Include details if any in JSON requests

This commit is contained in:
Asher 2020-07-23 12:23:33 -05:00
parent 58bd7008b4
commit c67d31580f
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
2 changed files with 3 additions and 1 deletions

View File

@ -9,7 +9,7 @@ export enum HttpCode {
}
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)
this.name = this.constructor.name
}

View File

@ -667,8 +667,10 @@ export class HttpServer {
if (request.headers["content-type"] === "application/json") {
write({
code,
mime: "application/json",
content: {
error: e.message,
...(e.details || {}),
},
})
} else {