Skip to content

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

Description

@peritus

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions