1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.transformException = void 0;
|
4 | const common_1 = require("@nestjs/common");
|
5 | const multer_constants_1 = require("./multer.constants");
|
6 | function 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 | }
|
23 | exports.transformException = transformException;
|