j3k0 / ganomede-boilerplate

boilerplates for ganomede microservices
0 stars 0 forks source link

Errors stack #10

Closed elmigranto closed 7 years ago

elmigranto commented 7 years ago

sendHttpError() prints error objects that it recieves, but that's not that useful, since stack points to internal places error was created from. While this is fine for GanomedeError instances and errors from restify (both of which are explicitly created by us inside callbacks), it's not that useful for stuff like socket hang up because theirs stack traces point in unhelpful places (like here https://github.com/j3k0/ganomede-directory/issues/15).

So replaces those stacks with new Error().stack or something similar.

This one is probably worth porting to other places, and not only fixing for future services.

elmigranto commented 7 years ago

@j3k0 should be better now https://github.com/j3k0/ganomede-boilerplate/commit/eec9dfdb313be9cad574aae820c45075ccd7a928

elmigranto commented 7 years ago

I wonder if we should add stack capturing for GanomedeError intances too, but I don't think we create those and call sendHttpError on different event loop ticks… yet?.. But I guess it's better to print same stuff twice, than look for the source for even half an hour :)

j3k0 commented 7 years ago

Great stuff. This GanomedeErrors module could be published on its own on npm (like restify did here with restify-errors https://github.com/restify/errors).

j3k0 commented 7 years ago

Yes, more stacktrace shouldn't hurt.