0

I have a very simple generator function, like this

exports.whatever = function *(next) {
  this.body = 'wow';
  z
};

Now, there obviously is a syntax error here ('z' on the third line), but with koa's generators, the error I get in the console is basically useless for debugging; I do not get the line of the error, the file, or even the type of error. All I get is:

Error: Generator is already running
    at GeneratorFunctionPrototype.next (native)
    at onFulfilled (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:59:19)
    at /Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:48:5
    at Object.co (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:47:10)
    at Object.toPromise (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:112:63)
    at next (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:93:29)
    at onRejected (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:79:7)

Is there any way to see the real detail of the error? Thanks in advance.

john doe
  • 121
  • 1
  • 10
  • Add some error-handling middleware. –  Feb 21 '15 at 07:42
  • Tried that, but it still gives the same error: `[Error: Generator is already running]` – john doe Feb 21 '15 at 07:57
  • Can you provide more context? I made few guesses at the rest of your code, but my simple tests show good error messages ie 'z' not defined with a reference to the file and line # – James Moore Feb 22 '15 at 22:03
  • Wow, you're right. Trying it for example from main.js gives the correct error. Try putting it inside `app.use(router(app)).get('/', function *(next){ x })` the router module is koa-router – john doe Feb 23 '15 at 08:27

0 Answers0