What is your custom exception hierrarchy?
Posted
by bonefisher
on Stack Overflow
See other posts from Stack Overflow
or by bonefisher
Published on 2010-04-29T11:54:44Z
Indexed on
2010/04/29
11:57 UTC
Read the original article
Hit count: 384
My question is: how would you create exception hierarchy in your application?
Designing the architecture of an application, from my perspective, we could have three types of exceptions:
- the built-in (e.g.: InvalidOperationException)
- custom internal system faults (DB transaction failed on commit, DbTransactionFailedException)
- custom business exceptions (BusinessRuleViolationException)
Class hierarchy:
- Exception
- MyAppInternalException
- DbTransactionFailedException
- MyServerTimeoutException
- ...
- MyAppBusinessRuleViolationException
- UsernameAlreadyExistsException
- ...
- MyAppInternalException
where only MyAppInternalException & MyAppBusinessRuleViolationException would be catched.
© Stack Overflow or respective owner