Skip to content

Commit

Permalink
fix registration error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
felixheck committed Jul 14, 2017
1 parent 5665d3a commit f70e134
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ function plugin (server, options, next) {

server.register(logger(options), (err) => {
if (err) {
console.error(err)
process.exit(1)
return next(err)
}

if (options.override) {
Expand Down
10 changes: 10 additions & 0 deletions test/init.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ test('throw error if plugin gets registered twice', (t) => {
t.throws(() => helpers.registerPlugin(helpers.getServer()), Error)
})

test('throw error if nested plugin throws error', (t) => {
t.throws(() => helpers.registerPlugin(helpers.getServer({
hapiPino: {
tags: {
foo: 'bar'
}
}
})), Error)
})

test('throw error if own options are invalid – colored', (t) => {
t.throws(() => helpers.getServer({
colored: null
Expand Down

0 comments on commit f70e134

Please sign in to comment.