Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Commit

Permalink
interceptor bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Waldmann committed Jun 23, 2015
1 parent fb1878c commit 3303ab7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions lib/base/interceptors.js
Expand Up @@ -114,30 +114,40 @@ exports.definition = {


addInterceptor: function(name, callback, priority){
var self = this;
priority = priority || 0;

if(this.interceptors[name]){

var fn = function(args, next){
var call_next = false;
try{
if(callback.length <= args.length){
//via return;

var result = callback.apply(this, args);

if(result === false) result = 'false'; //see async.applyEach below
if(!(result instanceof Error) && result !== 'false') result = null;
if(!(result instanceof Error) && result !== 'false') result = null;

call_next = true;
next(result);
}else{
//via next();
callback.apply(this, args.concat(function(result){
if(result === false) result = 'false'; //see async.applyEach below
if(!(result instanceof Error) && result !== 'false') result = null;

call_next = true;
next(result);
}));
}
}catch(e){
return next(e);
}catch(err){
if(!call_next){
return next(err);
}else{
self.store.handleException(err);
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "openrecord",
"version": "1.9.5",
"version": "1.9.6",
"description": "Active record like ORM for nodejs",
"keywords": ["orm", "record", "sql", "sqlite3", "postgres", "pg", "mysql", "database", "activerecord", "promise", "rest", "restify", "nested set", "ldap", "activedirectory", "active directory", "ad"],
"author": "Philipp Waldmann <philipp.waldmann@s-team.at>",
Expand Down

0 comments on commit 3303ab7

Please sign in to comment.