If you are rethrowing an exception to the UI layer (so the user will see it) is it always wise to rethrow a specific exception (Eg argumentnullexception)?
The problem I’ve seen with this is that it is too much technical information to he user. All I need to know is the problem and the cause, hiding any details and not even mention the word exception.
I saw the rethrowing of a specific exception in some code I was reviewing and was wondering if this is really recommended?
Thanks
What are you doing with the exception once it reaches the UI layer?
If you’re just letting the system exception handler catch it and shut down your program, then the more specific the better, because the user won’t be seeing it anyway.
If you’re catching it in the UI layer and telling the user what went wrong, then the more specific the better, and the UI layer can worry about “prettying it up” so that the user isn’t bamboozled by too much technical information.