@mrxsys/mrx-core 2.11.0-3-and-276-20251029 → 2.11.0-4-and-276-20251029

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.
@@ -1,51 +1,5 @@
1
1
  import { Elysia } from 'elysia';
2
- import { BaseError } from '../../../errors/base-error';
3
- import { HttpError } from '../../../errors/http-error';
4
2
  /**
5
3
  * The `errorPlugin` provides an error handling system for Elysia applications.
6
4
  */
7
- export declare const error: Elysia<"", {
8
- decorator: {};
9
- store: {};
10
- derive: {};
11
- resolve: {};
12
- }, {
13
- typebox: {};
14
- error: {
15
- readonly BaseError: BaseError<any>;
16
- readonly HttpError: HttpError<any>;
17
- };
18
- }, {
19
- schema: {};
20
- standaloneSchema: {};
21
- macro: {};
22
- macroFn: {};
23
- parser: {};
24
- response: {
25
- 200: {
26
- message: string;
27
- content: any;
28
- } | {
29
- message: "mrx-core.error.not_found";
30
- content?: never;
31
- } | {
32
- message: "mrx-core.error.parse";
33
- content?: never;
34
- } | {
35
- message: "mrx-core.error.internal_server_error";
36
- content?: never;
37
- };
38
- };
39
- }, {}, {
40
- derive: {};
41
- resolve: {};
42
- schema: {};
43
- standaloneSchema: {};
44
- response: {};
45
- }, {
46
- derive: {};
47
- resolve: {};
48
- schema: {};
49
- standaloneSchema: {};
50
- response: {};
51
- }>;
5
+ export declare const errorManager: Elysia;
@@ -1 +1 @@
1
- export { error } from './error';
1
+ export { errorManager } from './error';
@@ -16,61 +16,52 @@ import {
16
16
 
17
17
  // source/modules/elysia/error/error.ts
18
18
  import { Elysia } from "elysia";
19
- var error = new Elysia({
19
+ var errorManager = new Elysia({
20
20
  name: "errorPlugin"
21
21
  }).error({
22
22
  BaseError,
23
23
  HttpError
24
- }).onError(({ code, error: error2, set }) => {
24
+ }).onError(({ code, error, set, status }) => {
25
25
  set.headers["content-type"] = "application/json; charset=utf-8";
26
26
  switch (code) {
27
27
  case "HttpError":
28
- set.status = error2.httpStatusCode;
29
- return {
30
- message: error2.message,
31
- content: error2.cause
32
- };
28
+ return status(error.httpStatusCode, {
29
+ message: error.message,
30
+ content: error.cause
31
+ });
33
32
  case "BaseError":
34
- set.status = 500;
35
- return {
36
- message: error2.message,
37
- content: error2.cause
38
- };
33
+ return status(500, {
34
+ message: ERROR_KEYS.CORE_ERROR_INTERNAL_SERVER_ERROR,
35
+ content: error.cause
36
+ });
39
37
  case "VALIDATION": {
40
- set.status = 422;
41
- return {
42
- message: ERROR_KEYS.CORE_ERROR_VALIDATION,
43
- content: {
44
- on: error2.type,
45
- errors: error2.all.map((e) => ({
46
- path: e.path,
47
- value: e.value,
48
- summary: e.summary,
49
- message: e.schema?.error,
50
- schema: filterByKeyExclusion(e.schema, ["error"], true)
51
- }))
52
- }
53
- };
38
+ return status(422, {
39
+ on: error.type,
40
+ errors: error.all.map((e) => ({
41
+ path: e.path,
42
+ value: e.value,
43
+ summary: e.summary,
44
+ message: e.schema?.error,
45
+ schema: filterByKeyExclusion(e.schema, ["error"], true)
46
+ }))
47
+ });
54
48
  }
55
49
  case "NOT_FOUND":
56
- set.status = 404;
57
- return {
50
+ return status(404, {
58
51
  message: ERROR_KEYS.CORE_ERROR_NOT_FOUND
59
- };
52
+ });
60
53
  case "PARSE":
61
- set.status = 400;
62
- return {
54
+ return status(400, {
63
55
  message: ERROR_KEYS.CORE_ERROR_PARSE
64
- };
56
+ });
65
57
  case "INTERNAL_SERVER_ERROR":
66
58
  case "UNKNOWN":
67
59
  default:
68
- set.status = 500;
69
- return {
60
+ return status(500, {
70
61
  message: ERROR_KEYS.CORE_ERROR_INTERNAL_SERVER_ERROR
71
- };
62
+ });
72
63
  }
73
64
  }).as("global");
74
65
  export {
75
- error
66
+ errorManager
76
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrxsys/mrx-core",
3
- "version": "2.11.0-3-and-276-20251029",
3
+ "version": "2.11.0-4-and-276-20251029",
4
4
  "author": "Ruby",
5
5
  "devDependencies": {
6
6
  "@eslint/js": "^9.38.0",