fastify-file-interceptor
Version:
This library for Nestjs using FastifyAdapter it rely on library fastify-multer and express multer
24 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformException = void 0;
const common_1 = require("@nestjs/common");
const multer_constant_1 = require("./multer-constant");
function transformException(error) {
if (!error || error instanceof common_1.HttpException) {
return error;
}
switch (error.message) {
case multer_constant_1.multerExceptions.LIMIT_FILE_SIZE:
return new common_1.PayloadTooLargeException(error.message);
case multer_constant_1.multerExceptions.LIMIT_FILE_COUNT:
case multer_constant_1.multerExceptions.LIMIT_FIELD_KEY:
case multer_constant_1.multerExceptions.LIMIT_FIELD_VALUE:
case multer_constant_1.multerExceptions.LIMIT_FIELD_COUNT:
case multer_constant_1.multerExceptions.LIMIT_UNEXPECTED_FILE:
case multer_constant_1.multerExceptions.LIMIT_PART_COUNT:
return new common_1.BadRequestException(error.message);
}
return error;
}
exports.transformException = transformException;
//# sourceMappingURL=multer-utils.js.map