@grupodiariodaregiao/bunstone 0.3.11 → 0.3.12
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 +6 -3
- package/lib/app-startup.ts +5 -1
- package/lib/http-exceptions.ts +4 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -99813,8 +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
|
-
const
|
|
99817
|
-
super(
|
|
99816
|
+
const message = typeof response === "string" ? response : response.message ?? JSON.stringify(response);
|
|
99817
|
+
super(message);
|
|
99818
99818
|
this.status = status;
|
|
99819
99819
|
this.response = responseObj;
|
|
99820
99820
|
Object.setPrototypeOf(this, HttpException.prototype);
|
|
@@ -117125,7 +117125,10 @@ class AppStartup {
|
|
|
117125
117125
|
errors: errors5
|
|
117126
117126
|
};
|
|
117127
117127
|
}
|
|
117128
|
-
|
|
117128
|
+
set2.status = 500;
|
|
117129
|
+
return {
|
|
117130
|
+
message: error48 instanceof Error ? error48.message : "Internal Server Error"
|
|
117131
|
+
};
|
|
117129
117132
|
});
|
|
117130
117133
|
if (options?.cors) {
|
|
117131
117134
|
AppStartup.elysia.use(cors(options.cors));
|
package/lib/app-startup.ts
CHANGED
package/lib/http-exceptions.ts
CHANGED
|
@@ -10,17 +10,12 @@ export class HttpException extends Error {
|
|
|
10
10
|
) {
|
|
11
11
|
const responseObj =
|
|
12
12
|
typeof response === "string" ? { message: response } : response;
|
|
13
|
-
|
|
14
|
-
// to avoid JSON.stringify issues when error is serialized
|
|
15
|
-
const errorMessage =
|
|
13
|
+
const message =
|
|
16
14
|
typeof response === "string"
|
|
17
15
|
? response
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
? String(response.message)
|
|
22
|
-
: "Error";
|
|
23
|
-
super(errorMessage);
|
|
16
|
+
: ((response as { message?: string }).message ??
|
|
17
|
+
JSON.stringify(response));
|
|
18
|
+
super(message);
|
|
24
19
|
this.response = responseObj;
|
|
25
20
|
Object.setPrototypeOf(this, HttpException.prototype);
|
|
26
21
|
}
|