Include details if any in JSON requests

This commit is contained in:
Asher
2020-07-29 18:48:05 -05:00
parent 58bd7008b4
commit c67d31580f
2 changed files with 3 additions and 1 deletions
+1 -1
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
}
+2
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 {