Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 11, 2012 03:02 AM by ToughMan
Nov 04, 2012 06:08 PM|LINK
Hello - In a multi-tier SOA architecture, what kind of strategy do you use to handle database exceptions?
Do you include a property on your MessageContract response to pass some type of database exception information back to the user - maybe some type of error code the user can report back to the helpdesk?
Or do you catch the database exception at the middle tier, log it and then somehow report a generic FaultException back to the user - like maybe a custom DatabaseFaultException?
Nov 05, 2012 01:24 AM|LINK
I think it depends on how much information you'd like to provide (about the exceptions occured at datatbase side) to the front-end callers.
For simple case that you do not want too much encapsulation, you can just capture the database side exception and rethrow it with a new one (set the original one as inner exception) and let the runtime handle it. This will provide the raw exception information
to the up-stream callers.
You can also define your custom exceptions and always throw the custom exceptions to the front callers only. For example, you use a big try...catch... block to wrap the entire data accessing code block. Whenever exceptions occur(catched in your code block),
you create a new custom exception and only include the necessary information about the database side error( such as the target database, table, query info, invoked method ...). Thus the front-end callers will only receive the encapsulated error information.
Nov 05, 2012 02:14 AM|LINK
Nov 05, 2012 06:45 AM|LINK
Here is the
link which explain some of the best practice to handle the fault in wcf.
Hope it will help to solve your problem !!!
Nov 11, 2012 03:02 AM|LINK
Don't manage the whole exceptions in ur WCF, but use try……catch where you refer your WCF