compare error stack between egg@1
(co-base) and egg@2
(async-base)
// /app/service/test.js
class TestService extends Service {
echo() {
throw new Error('this is a error');
}
}
// {2.x}/app/controller/home.js
class HomeController extends Controller {
async index() {
this.ctx.body = await this.ctx.service.test.echo();
}
}
// {1.x}/app/controller/home.js
class HomeController extends Controller {
* index() {
this.ctx.body = yield this.ctx.service.test.echo();
}
}
- 1.x is missing
service/test.js
stack - 1.x had many boring co
next/onFulfilled
stack - 2.x is more straightforward
2017-11-22 08:43:46,599 ERROR 98784 [-/::1/-/5ms GET /] nodejs.Error: this is a error
at TestService.echo (/Users/tz/Workspaces/eggjs/test/showcase/app/service/test.js:7:11)
at HomeController.index (/Users/tz/Workspaces/eggjs/test/showcase/app/controller/home.js:7:49)
at Object.callFn (/Users/tz/Workspaces/eggjs/test/showcase/node_modules/[email protected]@egg-core/lib/utils/index.js:44:21)
at Object.classControllerMiddleware (/Users/tz/Workspaces/eggjs/test/showcase/node_modules/[email protected]@egg-core/lib/loader/mixin/controller.js:82:20)
at Object.callFn (/Users/tz/Workspaces/eggjs/test/showcase/node_modules/[email protected]@egg-core/lib/utils/index.js:44:21)
at wrappedController (/Users/tz/Workspaces/eggjs/test/showcase/node_modules/[email protected]@egg-core/lib/utils/router.js:317:18)
at dispatch (/Users/tz/Workspaces/eggjs/test/showcase/node_modules/[email protected]@koa-compose/index.js:44:32)
at next (/Users/tz/Workspaces/eggjs/test/showcase/node_modules/[email protected]@koa-compose/index.js:45:18)
at /Users/tz/Workspaces/eggjs/test/showcase/node_modules/[email protected]@koa-router/lib/router.js:345:16
at dispatch (/Users/tz/Workspaces/eggjs/test/showcase/node_modules/[email protected]@koa-compose/index.js:44:32)
2017-11-22 08:43:51,772 ERROR 98685 [-/127.0.0.1/-/6ms GET /] nodejs.Error: this is a error
at TestService.echo (/Users/tz/Workspaces/boom/egg-1.x/app/service/test.js:7:11)
at echo.next (<anonymous>)
at onFulfilled (/Users/tz/Workspaces/boom/egg-1.x/node_modules/[email protected]@co/index.js:65:19)
at /Users/tz/Workspaces/boom/egg-1.x/node_modules/[email protected]@co/index.js:54:5
at new Promise (<anonymous>)
at Object.co (/Users/tz/Workspaces/boom/egg-1.x/node_modules/[email protected]@co/index.js:50:10)
at Object.toPromise (/Users/tz/Workspaces/boom/egg-1.x/node_modules/[email protected]@co/index.js:118:63)
at next (/Users/tz/Workspaces/boom/egg-1.x/node_modules/[email protected]@co/index.js:99:29)
at onFulfilled (/Users/tz/Workspaces/boom/egg-1.x/node_modules/[email protected]@co/index.js:69:7)
at /Users/tz/Workspaces/boom/egg-1.x/node_modules/[email protected]@co/index.js:54:5