Giter Site home page Giter Site logo

api-error-handler's Issues

Best way to expose additional properties from http-errors

Trying to figure out how to best expose additional properties added to errors thru the http-errors package. Basically, what I'm trying to do is something like this:

const express = require('express')
const createError = require('http-errors')
const errorHandler = require('api-error-handler')

const app = express()

app.get('/test', function (req, res, next) {
  next(createError(400, { foobar: 10 }))
})

app.use(errorHandler())

I don't think it's explicitly stated, but I think that these two packages are made to work together.

Would be happy with any input, maybe I'm missing something simple.

One way would be to add an option (exposeAdditionalProperties maybe) that simply iterates and sets the properties. I'd be happy to send a PR!

Take a callback function?

Take a callback function and execute it at the end?

I am having a case that I want to log out the error message in console.
It will be easy to passing body into a callback function and execute it at the end process.

api.use(errorHandler(body => { console.log(body }))

I think it's easy for others who want to do more things with this lib. such as send an error email to the developer, etc.

Better documentation

I really like the feature that sets response status code from property status of the error thrown. It should be documented!

Is this repo dead?

Hello everyone,

I am still using this library as of today and I was wondering ?

Is this repo dead ?
Because I see many good ideas in pull requests and would really appreciate if you could merge some.

Have a good day !

Disable console.error()

A call to console.error() is present at line 22.

Would be nice to be able to disable it, especially when writing/running tests (can clutter the terminal output).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.