How should I throw Exceptions the correct way so that I dont lose any information?
Consider this example:
try {
this.stripe.customers.create({ ... });
} catch(e) {
throw new MyCustomCreateCustomersException();
}
In this case I can see in my logs that MyCustomCreateCustomersException
was thrown and where. But that stack trace does not include anything about whatever Stripe thrown, so the real error is lost here.
It is kind of obvious I guess since I left out e
and did not use it, but I am unsure about what is the best way of using it? I would like to have custom exceptions as well, that seems to be a good practice, but I don't want to lose any information deeper down.
MyCustomCreateCustomersException
is inheriting from Error
.