From c67d31580fdbc0fb2c58a7ce2c20d05e097d519d Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 23 Jul 2020 12:23:33 -0500 Subject: [PATCH] Include details if any in JSON requests --- src/common/http.ts | 2 +- src/node/http.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/http.ts b/src/common/http.ts index 8ecbaa34..4749247d 100644 --- a/src/common/http.ts +++ b/src/common/http.ts @@ -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 } diff --git a/src/node/http.ts b/src/node/http.ts index a4a83aea..62abeb07 100644 --- a/src/node/http.ts +++ b/src/node/http.ts @@ -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 {