Skip to content

Commit

Permalink
fix: resolve with hook error
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambie committed Nov 20, 2018
1 parent f82375e commit 68cebf5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions dadi/lib/model/collections/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,16 @@ function get ({
},
(error, resultsAfterHooks) => {
if (error) {
error.hook = this.settings.hooks.afterGet
let hook = new Hook({
hook: this.settings.hooks.afterGet[0]
}, 'afterGet')

logger.error({ module: 'model' }, error)
return reject(error)

return resolve({
results: hook.formatError(error[0].code),
metadata: {}
})
}

resolve(resultsAfterHooks)
Expand All @@ -126,8 +132,6 @@ function get ({
).then(results => {
return {results, metadata}
})
}).catch(err => {
return err
})
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ describe('Hook', function () {

hook.Hook.prototype.load.restore()

doc[0].code.indexOf('Cannot find module').should.be.above(0)
doc.results[0].details.indexOf('Cannot find module').should.be.above(0)

done()
})
Expand Down

0 comments on commit 68cebf5

Please sign in to comment.