可抛出的HTTP错误
节点API的Throwable HTTP错误。
安装
npm i throwable-http-errors
用法
const Errors = require ( 'throwable-http-errors' )
// for example, using express.js
router . post ( '/' , wrap ( async ( req , res , next ) => {
try {
if ( ! validatePet ( req . body ) ) {
throw new Errors . BadRequest ( )
}
const pet = await PetsController . create ( req . body )
res . send ( { status : t
评论0
最新资源