Skip to content

err.send(res) is documented but not implemented #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

Open
peritus opened this issue Jan 15, 2017 · 0 comments
Open

err.send(res) is documented but not implemented #3

peritus opened this issue Jan 15, 2017 · 0 comments

Comments

@peritus
Copy link

peritus commented Jan 15, 2017

Hey,

in
https://github.com/eoko/node-api-problem/tree/4071cfdcee096f9cbfd6c8d36b51ab6f032f2000#use-api-problem-in-a-middleware the README documents how to send errors in an express middleware like this:

err.send(res);

however, when I execute this:

> var ApiProblem = require('node-api-problem');
undefined
>
> var Issue12Problem = new ApiProblem('http://api.acme.com/kb/issues/12','Error documented by issue 12');
undefined
> Issue12Problem.send()

I get the following error message:

TypeError: Issue12Problem.send is not a function
    at repl:1:16
    at sigintHandlersWrap (vm.js:22:35)
    at sigintHandlersWrap (vm.js:96:12)
    at ContextifyScript.Script.runInThisContext (vm.js:21:12)
    at REPLServer.defaultEval (repl.js:313:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:513:10)
    at emitOne (events.js:101:20)
    at REPLServer.emit (events.js:188:7)

Grepping the repository doesn't mention send outside of the README :(

$> git log|head -n1
commit 4071cfdcee096f9cbfd6c8d36b51ab6f032f2000
$> git grep send
README.md:    err.send(res);

I've been using

res.set({
  'Content-Type': 'application/problem+json'
});
res.status(err.status);
res.send(err.toJSON());

in the meantime as a workaround, but maybe that should be part of this very library.

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

No branches or pull requests

1 participant