Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- ... // some code
- }
- catch (Exception ex)
- {
- ... // Do something
- throw new CustomException(ex);
- }
- try
- {
- ... // some code
- }
- catch (Exception ex)
- {
- .. // Do something
- throw ex;
- }
- try
- {
- ... // some code
- }
- catch (Exception ex)
- {
- .. // Do something
- throw;
- }
- try {
- // something that will raise an exception almost half the time
- } catch( InsufficientFunds e) {
- // Inform the customer is broke
- } catch( UnknownAccount e ) {
- // Ask for a new account number
- }
- try
- {
- // some code
- }
- catch (Exception ex) { throw ex; }
- try
- {
- // some code
- }
- catch (Exception ex) { throw; }
- public bool Load(string filepath)
- {
- if (File.Exists(filepath)) //Avoid throwing by checking state
- {
- //Wrap anyways in case something changes between check and operation
- try { .... }
- catch (IOException ioFault) { .... }
- catch (OtherException otherFault) { .... }
- return true; //Inform caller of success
- }
- else { return false; } //Inform caller of failure due to state
- }
Add Comment
Please, Sign In to add comment