UNPKG

json-api-nestjs

Version:
58 lines 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorInterceptors = void 0; const tslib_1 = require("tslib"); const common_1 = require("@nestjs/common"); // import { QueryFailedError, Repository } from 'typeorm'; // import { DriverUtils } from 'typeorm/driver/DriverUtils'; // // import { // CONTROL_OPTIONS_TOKEN, // CURRENT_ENTITY_REPOSITORY, // } from '../../constants'; // import { ConfigParam, Entity, ValidateQueryError } from '../../types'; // import { // MysqlError, // MysqlErrorCode, // PostgresError, // PostgresErrorCode, // } from '../../helper'; // import { HttpException } from '@nestjs/common'; // #TODO need implement let ErrorInterceptors = class ErrorInterceptors { // @Inject(CURRENT_ENTITY_REPOSITORY) private repository!: Repository<E>; // @Inject(CONTROL_OPTIONS_TOKEN) private config!: ConfigParam; intercept(context, next) { return next.handle(); // return next.handle().pipe( // catchError((error) => { // if (error instanceof QueryFailedError) { // return throwError(() => this.prepareDataBaseError(error)); // } // // if (error instanceof HttpException) { // return throwError(() => error); // } // // const errorObject: ValidateQueryError = { // code: 'internal_error', // message: this.config.debug ? error.message : 'Internal Server Error', // path: [], // }; // const descriptionOrOptions = this.config.debug ? error : undefined; // return throwError( // () => // new InternalServerErrorException( // [errorObject], // descriptionOrOptions // ) // ); // }) // ); } }; exports.ErrorInterceptors = ErrorInterceptors; exports.ErrorInterceptors = ErrorInterceptors = tslib_1.__decorate([ (0, common_1.Injectable)() ], ErrorInterceptors); //# sourceMappingURL=error.interceptors.js.map