@jrosadob/nestjs-sophia-framework
Version:
Franework para microservicios en NestJS
34 lines • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppUnauthorizedException = void 0;
const common_1 = require("@nestjs/common");
const nanoid_1 = require("../tools/nanoid");
const Logging = new common_1.Logger('AppUnauthorizedException');
class AppUnauthorizedException extends common_1.UnauthorizedException {
constructor(message) {
super(message);
}
getResponse() {
var _a;
const response = super.getResponse();
const loggerId = (0, nanoid_1.nanoid)();
if (typeof response === 'string') {
Logging.log(`[${loggerId}]: ${response}`);
return {
message: response,
error: 'Unauthorized',
statusCode: common_1.HttpStatus.UNAUTHORIZED,
loggerId: loggerId,
};
}
Logging.log(`[${loggerId}]: ${(_a = response.message) !== null && _a !== void 0 ? _a : response.error}`);
return {
error: 'Unauthorized',
message: response.message,
statusCode: common_1.HttpStatus.UNAUTHORIZED,
loggerId: loggerId,
};
}
}
exports.AppUnauthorizedException = AppUnauthorizedException;
//# sourceMappingURL=app-unauthorized.exception.js.map