@asapjs/error 1.0.0-alpha.28 → 1.0.0-alpha.29
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/helpers.d.ts +0 -2
- package/dist/helpers.js +10 -12
- package/package.json +5 -5
package/dist/helpers.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { Effect, Cause } from 'effect';
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { HttpErrorBody } from './types';
|
|
4
4
|
export declare function makeHttpError(status: number, errorCode: string, message: string, data?: Record<string, any>): HttpErrorBody;
|
|
5
|
-
/** 프레임워크 독립 — 에러를 HttpErrorBody로 정규화 */
|
|
6
|
-
export declare function resolveErrorBody(error: unknown): HttpErrorBody;
|
|
7
5
|
export declare function errorToResponse(error: unknown, res: Response): void;
|
|
8
6
|
export declare function causeToError(cause: Cause.Cause<unknown>): unknown;
|
|
9
7
|
export declare function runEffectAsPromise<A, E>(effect: Effect.Effect<A, E, never>): Promise<A>;
|
package/dist/helpers.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeHttpError = makeHttpError;
|
|
4
|
-
exports.resolveErrorBody = resolveErrorBody;
|
|
5
4
|
exports.errorToResponse = errorToResponse;
|
|
6
5
|
exports.causeToError = causeToError;
|
|
7
6
|
exports.runEffectAsPromise = runEffectAsPromise;
|
|
@@ -15,26 +14,25 @@ function makeHttpError(status, errorCode, message, data) {
|
|
|
15
14
|
data,
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
function errorToResponse(error, res) {
|
|
18
|
+
let errorBody;
|
|
20
19
|
if (error instanceof types_1.HttpError) {
|
|
21
|
-
|
|
20
|
+
errorBody = error.toJSON();
|
|
22
21
|
}
|
|
23
|
-
if (error && typeof error === 'object' && 'status' in error && 'message' in error && !('errorCode' in error)) {
|
|
22
|
+
else if (error && typeof error === 'object' && 'status' in error && 'message' in error && !('errorCode' in error)) {
|
|
24
23
|
// Legacy HttpException 지원
|
|
25
|
-
|
|
24
|
+
errorBody = {
|
|
26
25
|
status: error.status,
|
|
27
26
|
errorCode: 'LEGACY_HTTP_EXCEPTION',
|
|
28
27
|
message: error.message,
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
|
-
if (error && typeof error === 'object' && 'status' in error && 'errorCode' in error && 'message' in error) {
|
|
32
|
-
|
|
30
|
+
else if (error && typeof error === 'object' && 'status' in error && 'errorCode' in error && 'message' in error) {
|
|
31
|
+
errorBody = error;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
errorBody = new types_1.HttpError(500, 'INTERNAL_SERVER_ERROR', error instanceof Error ? error.message : '알 수 없는 서버 오류가 발생했습니다.').toJSON();
|
|
33
35
|
}
|
|
34
|
-
return new types_1.HttpError(500, 'INTERNAL_SERVER_ERROR', error instanceof Error ? error.message : '알 수 없는 서버 오류가 발생했습니다.').toJSON();
|
|
35
|
-
}
|
|
36
|
-
function errorToResponse(error, res) {
|
|
37
|
-
const errorBody = resolveErrorBody(error);
|
|
38
36
|
res.status(errorBody.status).json(errorBody);
|
|
39
37
|
}
|
|
40
38
|
function causeToError(cause) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asapjs/error",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.29",
|
|
4
4
|
"description": "Error handling utilities for ASAP.js with Effect integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"dev": "tsc --watch"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@asapjs/common": "^1.0.0-alpha.
|
|
16
|
-
"@asapjs/schema": "^1.0.0-alpha.
|
|
17
|
-
"@asapjs/types": "^1.0.0-alpha.
|
|
15
|
+
"@asapjs/common": "^1.0.0-alpha.29",
|
|
16
|
+
"@asapjs/schema": "^1.0.0-alpha.29",
|
|
17
|
+
"@asapjs/types": "^1.0.0-alpha.29",
|
|
18
18
|
"effect": "^3.11.11",
|
|
19
19
|
"express": "^4.20.0"
|
|
20
20
|
},
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "533aa5358d4945b000240d7bfec3037c475f6c44"
|
|
33
33
|
}
|