Open vuhrmeister opened 5 years ago
Hi @vuhrmeister, while I agree the logging is not great, I don't think we will change this until the next major. When we do that, I plan on having a whole lot more robust solution for logging. In the mean time, why not log an error instance? That way your error message would be logged properly.
Well, I can do that. It's just that the api I'm using is only returning an Object as error So I would always need to wrap it. Not the prettiest code then.
btw: just wrapping an object with an Error
doesn't change anything. A standard error also just excepts a string and prints Error: [object Object]
otherwise. The only additional information I get is the stack trace.
Hey, I mean an object is not an error. I am not sure this lib can solve this problem for you, and even my future logging efforts will require it to be a real Error
instance. I am guessing your object has some message in it, so something like new Error(obj.message)
would do the trick. Good luck.
I'm writing my own store class. Inside
save
orload
on exceptions I callfn(error)
. But iferror
is a plain Object then only this is being logged.The problem is, that the error is logged as a string: https://github.com/tj/node-migrate/blob/master/lib/log.js#L9
I would rather change it to something like this, thus making it more general: