UNPKG

1.06 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.transformException = void 0;
4const common_1 = require("@nestjs/common");
5const multer_constants_1 = require("./multer.constants");
6function transformException(error) {
7 if (!error || error instanceof common_1.HttpException) {
8 return error;
9 }
10 switch (error.message) {
11 case multer_constants_1.multerExceptions.LIMIT_FILE_SIZE:
12 return new common_1.PayloadTooLargeException(error.message);
13 case multer_constants_1.multerExceptions.LIMIT_FILE_COUNT:
14 case multer_constants_1.multerExceptions.LIMIT_FIELD_KEY:
15 case multer_constants_1.multerExceptions.LIMIT_FIELD_VALUE:
16 case multer_constants_1.multerExceptions.LIMIT_FIELD_COUNT:
17 case multer_constants_1.multerExceptions.LIMIT_UNEXPECTED_FILE:
18 case multer_constants_1.multerExceptions.LIMIT_PART_COUNT:
19 return new common_1.BadRequestException(error.message);
20 }
21 return error;
22}
23exports.transformException = transformException;