sealcode / sealious

An extensible, declarative node framework
25 stars 2 forks source link

Integrate boom #294

Closed adwydman closed 8 years ago

adwydman commented 8 years ago

This branch is still under construction.

@kuba-orlik I just want to make sure that this is what you want.

In chip-manager.js I replaced throw new Errors.ValidationError with throw new Boom.notFound. This is what this error prints:

{ Error: ChipManager was asked to return a chip of type "doesn't exist" and name "undefined", but it was not found
    at Object.ChipManager.__get_chip (C:\Users\anwi\Desktop\sealious\lib\chip-types\chip-manager.js:99:10)
    at Object.ChipManager.__get_chip_by_longid (C:\Users\anwi\Desktop\sealious\lib\chip-types\chip-manager.js:114:15)
    at C:\Users\anwi\Desktop\sealious\tests\unit-tests\chip-types\chip-manager.test.js:29:17
    at _tryBlock (assert.js:318:5)
    at _throws (assert.js:337:12)
    at Function.assert.throws (assert.js:367:3)
    at Context.<anonymous> (C:\Users\anwi\Desktop\sealious\tests\unit-tests\chip-types\chip-manager.test.js:27:10)
    at callFn (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\runnable.js:334:21)
    at Test.Runnable.run (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\runnable.js:327:7)
    at Runner.runTest (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\runner.js:429:10)
    at C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\runner.js:535:12
    at next (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\runner.js:349:14)
    at C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\runner.js:359:7
    at next (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\runner.js:285:14)
    at Immediate._onImmediate (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\runner.js:327:5)
    at tryOnImmediate (timers.js:543:15)
    at processImmediate [as _immediateCallback] (timers.js:523:5)
  data: null,
  isBoom: true,
  isServer: false,
  output:
   { statusCode: 404,
     payload:
      { statusCode: 404,
        error: 'Not Found',
        message: 'ChipManager was asked to return a chip of type "doesn\'t exist" and name "undefined", but it was not found' },
     headers: {} },
  reformat: [Function] }
kuba-orlik commented 8 years ago

Hmmm that doesn't seem right - I think that we should use Boom only for user-facing errors. We can just throw new Error("message") in all the other places - they will show up in the logger, but in user-facing output :)

adwydman commented 8 years ago

I see. Well, previously this message was in ValidationError, not a regular Error. I think this branch can help us specify which errors are for the developers and which are for users. :)

kuba-orlik commented 8 years ago

Surely. Do you need some more assistance right now?

adwydman commented 8 years ago

No, I want to do it myself.

adwydman commented 8 years ago

@kuba-orlik Please check the changes know, I've made them in collection.js and chip-manager.js.

kuba-orlik commented 8 years ago

Adrian rightfully noted that using Boom would favor REST and make Sealious less channel-agnostic. We've agreed not to do that.