0

I come from java, when I got an expected error I printed stack traces. I'm coming now to work on nodejs (never really worked on javascript). and in the nodejs project which I need to maintain (project was already coded by other javascript developers) I see error logging following:

logger.error('some message ' + e.message)

or

logger.error('some message ' + e);

or

logger.error('some message ' + e.toString());

or

logger.error('some message');

I saw no stacktraces in logs. Coming from java I converted a few errors to:

logger.error('some message ' + e.stack)

but then when a peer javascript developer reviewed that he had a bad eye on me and asked me why do I do that? I told him if the error is unexpected we want all the information about it. He was very upset that I want the stack and not the message, his claim is that it would clutter the logs, so I said but the error is unexpected, he told me this is nodejs here no stacktraces here. I still want .stack but all the javascript developers do not want it they think it's bad practice to print the .stack, I feel I lose important information. We ended up by him changing my .stack to .message.

I looked at logs and sometimes the .stack just prints two lines not much of a stack, however for me the first line where it printed the filename and the line number where the problem happened is justifying the stack, the javascript developer claim in this case was I can search the error message in code and find it, for me that is not suffice because i don't think this is scalable a day would come where we would find multiple places with the same printing and if we had a stack we would know exactly which file printed the error and in certain cases also have stack.

Coming from java to javascript - am i missing something? should I do e.message and not e.stack? am i taking something from java that i should not be?

thanks

  • Nice edit, but make sure you clean up your spelling and grammatical errors also. – Robert Harvey Jun 29 '16 at 14:34
  • For the record, we're not really here to solve coworker disputes. Find a level of detail in the log that everyone can be happy with, and stick to that. – Robert Harvey Jun 29 '16 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.