@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 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 errorMessage = typeof response === "string" ? response : typeof response === "object" && response !== null && ("message" in response) ? String(response.message) : "Error";
99817
- super(errorMessage);
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
- return error48;
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));
@@ -142,7 +142,11 @@ export class AppStartup {
142
142
  };
143
143
  }
144
144
 
145
- return error;
145
+ set.status = 500;
146
+ return {
147
+ message:
148
+ error instanceof Error ? error.message : "Internal Server Error",
149
+ };
146
150
  });
147
151
 
148
152
  if (options?.cors) {
@@ -10,17 +10,12 @@ export class HttpException extends Error {
10
10
  ) {
11
11
  const responseObj =
12
12
  typeof response === "string" ? { message: response } : response;
13
- // Extract a simple message string for the Error base class
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
- : typeof response === "object" &&
19
- response !== null &&
20
- "message" in response
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
  }
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "types": "./dist/*.d.ts"
14
14
  }
15
15
  },
16
- "version": "0.3.11",
16
+ "version": "0.3.12",
17
17
  "homepage": "https://bunstone.diario.one/",
18
18
  "repository": {
19
19
  "url": "https://github.com/diariodaregiao/bunstone.git",