I’m build an UserControl and I’m not sure how to handle exceptions, the Control itself is not very complicated, the User chose an image from disk so they can authorize it, I don’t know exactly how the control will be used so if I use a MessageBox I might block the application, and if I just re-throw it I might crash it.
thanks in advance.
Juan Zamudio
this is a common problem facing developers who build libraries. Try to weed out bugs and decide for the remaining error cases if it’s an expected error (your control should not throw an exception but rather gracefully handle the error) or an unexpected exceptional condition (your control must throw an exception as soon as possible).
You might also have a look at Design By Contract, a methodology to declare required preconditions and guaranteed postconditions. This may sound academic, but it leads to more robust code.
UPDATE: A good introduction is http://se.ethz.ch/~meyer/publications/computer/contract.pdf
Regards, tamberg