jeudi 24 août 2017

What's the best practice to structure exception messages?

When something goes wrong in your program, you can throw an exception in your code with a message that describes a problem. Typical example:

throw new Exception("Houston we have a problem");

Is it a good practice to pass a hardcoded string into an exception constructor? Maybe I should hold all of exception messages in a one place. Please tell me what's the best practice to solve a problem of exception message structuring.

Aucun commentaire:

Enregistrer un commentaire