@grupodiariodaregiao/bunstone 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -1
- package/lib/http-exceptions.ts +11 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -99813,7 +99813,8 @@ class HttpException extends Error {
|
|
|
99813
99813
|
response;
|
|
99814
99814
|
constructor(response, status) {
|
|
99815
99815
|
const responseObj = typeof response === "string" ? { message: response } : response;
|
|
99816
|
-
|
|
99816
|
+
const errorMessage = typeof response === "string" ? response : typeof response === "object" && response !== null && ("message" in response) ? String(response.message) : "Error";
|
|
99817
|
+
super(errorMessage);
|
|
99817
99818
|
this.status = status;
|
|
99818
99819
|
this.response = responseObj;
|
|
99819
99820
|
Object.setPrototypeOf(this, HttpException.prototype);
|
package/lib/http-exceptions.ts
CHANGED
|
@@ -10,7 +10,17 @@ export class HttpException extends Error {
|
|
|
10
10
|
) {
|
|
11
11
|
const responseObj =
|
|
12
12
|
typeof response === "string" ? { message: response } : response;
|
|
13
|
-
|
|
13
|
+
// Extract a simple message string for the Error base class
|
|
14
|
+
// to avoid JSON.stringify issues when error is serialized
|
|
15
|
+
const errorMessage =
|
|
16
|
+
typeof response === "string"
|
|
17
|
+
? response
|
|
18
|
+
: typeof response === "object" &&
|
|
19
|
+
response !== null &&
|
|
20
|
+
"message" in response
|
|
21
|
+
? String(response.message)
|
|
22
|
+
: "Error";
|
|
23
|
+
super(errorMessage);
|
|
14
24
|
this.response = responseObj;
|
|
15
25
|
Object.setPrototypeOf(this, HttpException.prototype);
|
|
16
26
|
}
|