nodejs mysql error handling with user example
catch (err) {
if (err instanceof Errors.BadRequest)
return res.status(HttpStatus.BAD_REQUEST).send({ message: err.message }); // 400
if (err instanceof Errors.Forbidden)
return res.status(HttpStatus.FORBIDDEN).send({ message: err.message }); // 403
if (err instanceof Errors.NotFound)
return res.status(HttpStatus.NOT_FOUND).send({ message: err.message }); // 404
if (err instanceof Errors.UnprocessableEntity)
return res.status(HttpStatus.UNPROCESSABLE_ENTITY).send({ message: err.message }); // 422
console.log(err);
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).send({ error: err, message: err.message });
}
Also in JavaScript:
- react dynamic settings
- javascript bubble sort
- timestamp to date javascript
- random numbers javascript
- javascript for loop return index
- jquery loop through list element
- electron check if file exists
- how to update value in nested json using id in javascript
- change color by click event javascript
- Build JavaScript Objects
- jquery add text to textbox
- how to save in p5 js
- jquery remove multiple classes
- react native textinput disable keyboard
- Amazon VPC supporting 5 different IP address ranges and i wanted to know how wide those rangers are
- [SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()
- vscode new file shortcut
- how to create an array in javascript
- angular 1 decorator example
- react native webview
- react html symbol code
- js date of tomorrow
- print pdf javascript
- js modulo not working