Comments (6)
We match the way throw
works only:
$ node
> throw {message: 'server error', status: 401}
[object Object]
from errorhandler.
Actually, I was thinking this was a different module. Since this module's only purpose is for debugging, we can change it to use util.inspect
to stringify non-Error objects. I would still highly discourage you from using those, mainly because you don't get a stack trace and so they are of marginal use.
from errorhandler.
I'm thinking both, correction of this module and correction of my code.. What I get used to use is returning simple object into callback, signaling there is an error. As far as I can see, many projects still using that, isn't it?
I would still highly discourage you from using those, mainly because you don't get a stack trace and so they are of marginal use.
It makes sense, probably Error
is better. Anyways, it will be nice if both Error
and non-Error
object have clear output.
from errorhandler.
far as I can see, many projects still using that, isn't it?
That doesn't mean they should; the value you pass as err
should always be an instanceof Error
as it it should always be something would would have throw
n.
from errorhandler.
Will take into consideration. So, for that particular case - if think it's enough to
// write error to console
if (env !== 'test') {
console.error(err.stack || err)
}
If you are fine with that, I can pack an PR.
Btw, it says development-only
purpose? What's recommended to use in production.. or only custom one?
from errorhandler.
So, for that particular case - if think it's enough to
No, use util.inspect
-- we want to only send a string to console.error
, really. The other things should be changed too, the text/plain
and the html responses should also be changed to use util.inspect
.
Btw, it says development-only purpose? What's recommended to use in production.. or only custom one?
A custom one or use nothing and let the express built-in stuff handle it. Using this will leak internal information to customers, like error messages and stack traces. This means if someone puts a '
in an input field and sees the SQL syntax incorrect error message, they instantly know you have a SQL injection vulnerability.
from errorhandler.
Related Issues (13)
- remove directory CSS
- read statusCode from err.statusCode? HOT 5
- Proposal: suppress stack traces in HTTP responses when running in production HOT 13
- More readable output formats HOT 1
- Can't get errorhandler to work in Express 4 HOT 7
- missing semicolon in README.md usage HOT 2
- Allow to change output structor HOT 3
- No matching version found for errorhandler@^1.5.1 HOT 4
- 'errorhandler@^1.5.0' is not in the npm registry HOT 2
- setting status code HOT 5
- Nothing displayed when error doesn't contain a .stack HOT 3
- Please clarify copyright HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from errorhandler.