Skip to content

Commit

Permalink
Added error example
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonnelldean committed Sep 16, 2016
1 parent f3f4b75 commit f66d54e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/examples/error-handling.js
@@ -0,0 +1,32 @@
'use strict'

var Seneca = require('../../')

var local = Seneca({log: 'test'})
var server = Seneca({log: 'test'})

var plugin = function () {
this.add('role:cause,cmd:err', (msg, done) => {
throw new Error('foo')
done()
})
}


server
.use(plugin)
.ready(() => {

server.listen({pin: 'role:cause,cmd:*', port: 4050})

local.ready(() => {

local.client({pin: 'role:cause,cmd:*', port: 4050})
setInterval(() => {
local.act('role:cause,cmd:err', (err, reply) => {
console.log(err)
})

}, 1000)
})
})

0 comments on commit f66d54e

Please sign in to comment.