Newer
Older
import { HttpException } from '@nestjs/common';
export function handleError(err, defaultErr) {
if (err instanceof HttpException) {
throw err;
} else {
if (err && err.error) {
const error = JSON.parse(err.error);
throw new HttpException(error.message, err.statusCode);
} else {
throw defaultErr;
}
}
}