try catch处理错误,例如:参数校验失败
throw new Error,处理的错误,都是已知的错误
已知异常
已知异常,response里面有 code码
{"message": "","code": 1001,"requestUrl": "",}
抛出异常
if(!ctx.request.query) {const error = new Error('error message');error.code = 1001;error.status = 400;error.requestUrl = `${ctx.method} ${ctx.path}`;throw error;}
未知异常
程序潜在错误,
无意识的错误,例如数据库密码不对
