Skip to content

Oh No! HTTP => require('ono/http'); #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

danieljoppi
Copy link

Suggestion to issue #2

const ono = require('ono/http');

throw ono.badRequest('Missing ID');

output

{
  "status": 400,
  "name": "Error",
  "message": "Missing ID",
  "stack": "Error: Missing ID
    at Object.exports.(anonymous function) [as badRequest] (/ono/http/index.js:12:19)
    at repl:1:9
    at ContextifyScript.Script.runInThisContext (vm.js:44:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:440:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)"
}

throw ono.badRequest('Missing ID');

{
  "status": 400,
  "name": "Error",
  "message": "Missing ID",
  "stack": "Error: Missing ID
    at Object.exports.(anonymous function) [as badRequest] (/ono/http/index.js:12:19)
    at repl:1:9
    at ContextifyScript.Script.runInThisContext (vm.js:44:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:440:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)"
}
@coveralls
Copy link

coveralls commented Sep 5, 2017

Coverage Status

Coverage remained the same at 98.058% when pulling 1dbeddd on danieljoppi:feature/http-errors into ac53fdc on BigstickCarpet:master.

@JamesMessinger
Copy link
Member

JamesMessinger commented Sep 6, 2017

I like this idea, and I think your implementation is clever too. I didn't know about the statuses package before. It's pretty cool/useful.

However, I think this should be a separate npm package (e.g. ono-http) rather than part of the main ono package.

@danieljoppi
Copy link
Author

ono-http is great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants