Permalink
Browse files

Added error example

  • Loading branch information...
1 parent f3f4b75 commit f66d54ef4873bd7624db52288226fc3857c14f81 @mcdonnelldean mcdonnelldean committed Sep 16, 2016
Showing with 32 additions and 0 deletions.
  1. +32 −0 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.