mongoose#Error TypeScript Examples
The following examples show how to use
mongoose#Error.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: mongo.exceptions.ts From uniauth-backend with MIT License | 6 votes |
@Catch(Error)
export class MongoExceptionFilter implements ExceptionFilter {
catch(error: any) {
if (error.name === 'ValidationError') {
const errors = {};
Object.keys(error.errors).forEach((key) => {
errors[key] = error.errors[key].message;
});
throw new BadRequestException(errors);
}
}
}
Example #2
Source File: Logger.ts From Asena with MIT License | 5 votes |
static formatError(e: Error){
return {
stack: e.stack.split(`\n`).map(line => line.trim()),
name: e.name
}
}