Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Can an exception be handled in another class, assembly, or abstract class?
- public class StackUserDataSource : AbstractEnhancedTableDataSource<StackUserDataServiceContext>
- {
- //.. stuff
- public IEnumerable<StackUserDataModel> Select()
- {
- try
- {
- var results = from c in _ServiceContext.StackUserTable
- select c;
- var query = results.AsTableServiceQuery();
- var queryResults = query.Execute();
- return queryResults;
- }
- catch (StorageClientException e)
- {
- // Todo: consider sticking this in another central location
- switch (e.ErrorCode)
- {
- case StorageErrorCode.AccessDenied:
- break;
- case StorageErrorCode.AccountNotFound:
- break;
- case StorageErrorCode.AuthenticationFailure:
- break;
- // ... Yadda yadda, handle some exceptions, not others.. this is a demo.
- case StorageErrorCode.TransportError:
- break;
- default:
- break;
- }
- throw;
- }
- }
- try
- {
- var results = from c in _ServiceContext.StackUserTable
- select c;
- var query = results.AsTableServiceQuery();
- var queryResults = query.Execute();
- return queryResults;
- }
- catch (MyExternalExceptionHelperDLL e)
- {
- // all exceptions referenced in MyExternalHelper are passed below
- MyExternalExceptionHelper.ProcessException(e);
- }
- catch (exception)
- {
- }
- try
- {
- var results = from c in _ServiceContext.StackUserTable
- select c;
- var query = results.AsTableServiceQuery();
- var queryResults = query.Execute();
- return queryResults;
- }
- catch (exception e)
- {
- MyExternalExceptionHelper.ProcessException(e);
- // The problem is that I don't know how to catch exceptions thrown from that static method above,
- // or how to override that exception handling...
- }
- public IEnumerable<StackUserDataModel> Select()
- {
- try
- {
- ...
- }
- catch (StorageClientException e)
- {
- // You could do this if there is no fancy processing to do
- if (!IsCatchableException(e))
- throw;
- }
- }
- bool IsCatchableException(StorageClientException e)
- {
- ... optionally do some fancy processing of the exception, e.g. logging....
- switch (e.ErrorCode)
- {
- case StorageErrorCode.AccessDenied:
- case StorageErrorCode.AccountNotFound:
- ....
- return true;
- }
- }
Add Comment
Please, Sign In to add comment