apparatus / mu

A message based router for building distributed systems
MIT License
26 stars 1 forks source link

first args in callbacks must be Errors #22

Closed mcollina closed 8 years ago

mcollina commented 8 years ago

as titled, in several places are strings or objects

davidmarkclements commented 8 years ago

you mean the Error constructor?

They're a bit awkward though

JSON.stringify(Error('foo')) // {}

You'd have to do

var err = Error()
err.message = 'foo'
JSON.stringify(err) // {"message": "foo"}

Agreed the approach should be consistent, maybe a little mu-error module or something that keeps error generation consistent?

mcollina commented 8 years ago

Yes. We need to do something like https://www.npmjs.com/package/boom.

irelandm commented 8 years ago

I’m having a problem with this - the err and res seems to get screwed up when there is an err (of type Error): e.g. Wiring error: Error: not found Wiring result: undefined

Client error: {} Client result: { err: {} }

irelandm commented 8 years ago

And if I return a string 'not found' as the err, I get:

Client error: not found Client result: { err: 'not found' }

When I was really expecting an empty (undefined) result

davidmarkclements commented 8 years ago

fixed in https://github.com/apparatus/mu/pull/41