Skip to content

Commit

Permalink
fixing an issue with error reporting for generators.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Dec 6, 2015
1 parent a23295b commit b65e6d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
6 changes: 1 addition & 5 deletions lib/async.js
Expand Up @@ -20,11 +20,7 @@ function asyncAdapter(generator) {
});
}

try {
return handle(g.next());
} catch (ex) {
return $p.reject(ex);
}
return handle(g.next());
}
}

Expand Down
15 changes: 5 additions & 10 deletions lib/index.js
Expand Up @@ -457,14 +457,6 @@ function $extend(ctx, obj) {
}
}

// support for generators;
if (cb.constructor.name === 'GeneratorFunction') {
taskCtx.cb = $npm.async(cb);
if ('txMode' in cb) {
taskCtx.cb.txMode = cb.txMode;
}
}

var tsk = new Task(taskCtx, tag, isTX);

if (taskCtx.db) {
Expand Down Expand Up @@ -754,9 +746,12 @@ function $task(ctx, obj, isTX) {

// callback invocation helper;
function callback() {
var result;
var result, cb = ctx.cb;
if (cb.constructor.name === 'GeneratorFunction') {
cb = $npm.async(cb);
}
try {
result = ctx.cb.call(obj, obj); // invoking the callback function;
result = cb.call(obj, obj); // invoking the callback function;
} catch (err) {
$notify.error(ctx.options, err, {
client: ctx.db.client,
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "pg-promise",
"version": "2.7.1",
"version": "2.7.2",
"description": "PostgreSQL via promises",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit b65e6d8

Please sign in to comment.