Disable console.error() #3
Comments
@tkrotoff If you're running into |
i don't mind a flag, but yeah, there's almost no reason these should be logged even in testing since you should be handling them. |
As said, I'm not talking about production. What is your workflow when working on an Express app? As of myself, I do write unit tests for failure cases like: it('should not create a user without a name', done => {
request(app).post('/Users/')
.send({}) // Instead of {name: 'Edgar'}
.expect(500) // Checks an error occurred
.end((err, res) => {
// blabla
});
}); but then I end up with hundreds of lines like this one in my terminal (*):
lines that I don't care about in testing mode: jasmine/mocha already tells me if something is wrong. (*) that don't occur when Edit: error 500 instead of 422 |
well 1, that's a server error so it should be logging that error. your app should be handling the error. 2, it's not a 5xx error, so that that line in this module shouldn't be what's logging the error |
Pretend you did not see the 422 (I've edited the example) :)
I see, my mistake, I should never ever have 5xx errors. My code lazily pass all PostgreSQL errors to api-error-handler ( To follow with the above example: if someone tries to create a user without a name, I should parse the PostgreSQL error and return 422 because of "Integrity Constraint Violation" (23502) instead of letting api-error-handler returning 500. Hence my terminal cluttered by logs from api-error-handler, sorry for the bad report. |
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).
The text was updated successfully, but these errors were encountered: