Suppose I have three functions doA (), doB () and doC () in a C # program, where I know that doA () will call doB (), which in turn will call doC ().
Since doC () needs to interact with the database, I know that it may well throw exceptions that it cannot decide what needs to be brought to the attention of the user. At the moment, I have some code that can cause an error in trying / catching in doC (), and then calling doC () in doB () in another try / catch and similarly calling doB () in doA () in a try block / catch. This allows me to simply use the cast; to throw an exception to doA (), where you can do something reasonable to display this to the user.
This is a bit like overkill. I am wondering if I do not plan to deal with the exception in doB () or doC (), if I can just get rid of the try / catch blocks there.
Assuming the blocks are ultimately not involved, what is the best practice for situations like this?
source
share