m
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import { ExceptionFilter, ArgumentsHost, HttpException } from '@nestjs/common';
|
||||
export declare class HttpExceptionFilter implements ExceptionFilter {
|
||||
catch(exception: HttpException, host: ArgumentsHost): void;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HttpExceptionFilter = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let HttpExceptionFilter = class HttpExceptionFilter {
|
||||
catch(exception, host) {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse();
|
||||
const status = exception.getStatus();
|
||||
try {
|
||||
const res = exception.getResponse();
|
||||
const message = typeof res == 'string' ? res : res.message;
|
||||
const msg = Array.isArray(message) ? message.join(',') : message;
|
||||
response.status(status).send({
|
||||
msg,
|
||||
code: status,
|
||||
success: false,
|
||||
});
|
||||
}
|
||||
catch {
|
||||
response.status(status).send(exception.getResponse());
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.HttpExceptionFilter = HttpExceptionFilter;
|
||||
exports.HttpExceptionFilter = HttpExceptionFilter = __decorate([
|
||||
(0, common_1.Catch)(common_1.HttpException)
|
||||
], HttpExceptionFilter);
|
||||
//# sourceMappingURL=http_exception.filter.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"http_exception.filter.js","sourceRoot":"","sources":["../../../../src/app/common/exception/http_exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AAIjB,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,KAAK,CAAC,SAAwB,EAAE,IAAmB;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAE7C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAEC,CAAC;YAEnC,MAAM,OAAO,GAAG,OAAO,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;YAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAEjE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;gBAC3B,GAAG;gBACH,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF,CAAA;AAvBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,cAAK,EAAC,sBAAa,CAAC;GACR,mBAAmB,CAuB/B"}
|
||||
Reference in New Issue
Block a user