import { HttpException, HttpStatus } from '@nestjs/common'; export class LontaraException { static showError(error: any): HttpException { let message = ''; if (typeof error === 'string') { message = error; } else { message = error.message; } const splitError = message.split(':'); if (splitError.length > 1) { if (splitError[0].length == 3 && /^\d{3}/.test(splitError[0])) { throw new HttpException(splitError[1].trim(), parseInt(splitError[0])); } throw new HttpException(message, HttpStatus.INTERNAL_SERVER_ERROR); } throw new HttpException(message, HttpStatus.INTERNAL_SERVER_ERROR); } }