@yolo-croket-dev/core 1.8.7-beta.4 → 1.8.7-beta.6

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,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class BadRequest extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class BadRequest extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class Conflict extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class Conflict extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,13 +1,16 @@
1
1
  import { HttpException } from '@nestjs/common';
2
+ import { ErrAction } from '../interfaces/exception';
3
+ import { MsaException } from '../interfaces/msa-exception';
2
4
  /**
3
5
  * Forbidden 지원
4
6
  * Type O
5
7
  * ErrAction X
6
8
  */
7
- export declare class Forbidden extends HttpException {
9
+ export declare class Forbidden extends HttpException implements MsaException {
8
10
  subMessage: string | null;
9
11
  errType: string | null;
10
12
  errMessage: string | null;
13
+ errAction: ErrAction | null;
11
14
  /** 해당 에러시 재시도 여부 */
12
15
  isRetry?: boolean;
13
16
  constructor(errType: string, errMessage?: string, isRetry?: boolean);
@@ -15,10 +15,12 @@ class Forbidden extends common_1.HttpException {
15
15
  // new
16
16
  this.errType = null;
17
17
  this.errMessage = null;
18
+ this.errAction = null;
18
19
  this.subMessage = errMessage || null;
19
20
  // new
20
21
  this.errType = errType || null;
21
22
  this.errMessage = errMessage || null;
23
+ this.errAction = null;
22
24
  this.isRetry = isRetry;
23
25
  }
24
26
  }
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class Gone extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class Gone extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class InternalServerError extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class InternalServerError extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class MethodNotAllowed extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class MethodNotAllowed extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class NotAcceptable extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class NotAcceptable extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class NotFound extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class NotFound extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,9 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class ServerPauseException extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class ServerPauseException extends HttpException implements MsaException {
5
+ errType: string | null;
6
+ errMessage: string | null;
4
7
  errAction: ErrAction | null;
5
8
  constructor(serverPauseTitle: string, serverPauseMessage: string);
6
9
  }
@@ -6,7 +6,11 @@ const exception_1 = require("../interfaces/exception");
6
6
  class ServerPauseException extends common_1.HttpException {
7
7
  constructor(serverPauseTitle, serverPauseMessage) {
8
8
  super('SERVER_PAUSE_EXCEPTION', common_1.HttpStatus.SERVICE_UNAVAILABLE);
9
+ this.errType = null;
10
+ this.errMessage = null;
9
11
  this.errAction = null;
12
+ this.errType = 'SERVER_PAUSE_EXCEPTION';
13
+ this.errMessage = serverPauseMessage;
10
14
  this.errAction = {
11
15
  type: exception_1.ErrActionTypeEnum.SERVER_PAUSE,
12
16
  serverPauseTitle,
@@ -1,11 +1,12 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
+ import { MsaException } from '../interfaces/msa-exception';
3
4
  /**
4
5
  * UnAuthorized 지원
5
6
  * Type X
6
7
  * ErrAction X
7
8
  */
8
- export declare class UnAuthorized extends HttpException {
9
+ export declare class UnAuthorized extends HttpException implements MsaException {
9
10
  subMessage: string | null;
10
11
  errType: string | null;
11
12
  errMessage: string | null;
@@ -2,3 +2,4 @@ export * from './http';
2
2
  export * from './decorator';
3
3
  export * from './exception';
4
4
  export * from './amqp';
5
+ export * from './msa-exception';
@@ -18,3 +18,4 @@ __exportStar(require("./http"), exports);
18
18
  __exportStar(require("./decorator"), exports);
19
19
  __exportStar(require("./exception"), exports);
20
20
  __exportStar(require("./amqp"), exports);
21
+ __exportStar(require("./msa-exception"), exports);
@@ -0,0 +1,25 @@
1
+ import { HttpException } from '@nestjs/common';
2
+ import { ErrAction } from './exception';
3
+ /**
4
+ * @author jun
5
+ * @description MSA 아키텍처에서 사용하는 공통 예외 인터페이스
6
+ * @process 커스텀 예외 클래스들이 구현하여 일관된 에러 처리 가능
7
+ */
8
+ export interface MsaException {
9
+ /** 에러 유형 코드 */
10
+ errType: string | null;
11
+ /** 에러 메시지 */
12
+ errMessage: string | null;
13
+ /** 클라이언트 액션 정보 */
14
+ errAction: ErrAction | null;
15
+ /** 재시도 가능 여부 */
16
+ isRetry?: boolean;
17
+ }
18
+ /** HttpException과 MsaException을 결합한 타입 */
19
+ export type MsaHttpException = MsaException & HttpException;
20
+ /**
21
+ * @description MsaException 타입 가드
22
+ * @param error 검사할 에러 객체
23
+ * @returns MsaHttpException 타입 여부
24
+ */
25
+ export declare function isMsaException(error: unknown): error is MsaHttpException;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMsaException = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ /**
6
+ * @description MsaException 타입 가드
7
+ * @param error 검사할 에러 객체
8
+ * @returns MsaHttpException 타입 여부
9
+ */
10
+ function isMsaException(error) {
11
+ if (!error || typeof error !== 'object') {
12
+ return false;
13
+ }
14
+ const err = error;
15
+ return ('errType' in err
16
+ && 'errMessage' in err
17
+ && 'errAction' in err
18
+ && error instanceof common_1.HttpException);
19
+ }
20
+ exports.isMsaException = isMsaException;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.8.7-beta.4",
3
+ "version": "1.8.7-beta.6",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@yolo-croket-dev/logger": "^1.0.15",
24
- "@yolo-croket-dev/msa-logger": "^3.3.2",
24
+ "@yolo-croket-dev/msa-logger": "^3.4.0",
25
25
  "@yolo-croket-dev/redis": "^1.0.25",
26
26
  "axios": "^1.1.3",
27
27
  "dd-trace": "^5.46.0",