expressjs / api-error-handler Goto Github PK
View Code? Open in Web Editor NEWExpress error handlers for JSON APIs
License: MIT License
Express error handlers for JSON APIs
License: MIT License
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.
I really like the feature that sets response status code from property status
of the error thrown. It should be documented!
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).
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 !
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!
Hi guys. Can we do this? Otherwise tests become messy.
if (process.env.NODE_ENV === "test") {
// no `stack` in the response
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.