Skip to content
Snippets Groups Projects
Unverified Commit 7dd4180f authored by syuilo's avatar syuilo
Browse files

Better error handling

parent 55821349
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,15 @@ export default (endpoint: IEndpoint, ctx: Koa.BaseContext) => new Promise((res)
ctx.status = 204;
} else if (typeof x === 'number') {
ctx.status = x;
ctx.body = { error: y };
ctx.body = {
error: {
message: y.message,
code: y.code,
id: y.id,
kind: y.kind,
...(y.info ? { info: y.info } : {})
}
};
} else {
ctx.body = x;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment