Click here to Skip to main content
16,012,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've a WPF MVVM Prism application.I want to display User friendly error messages during exception.I need to implement this in the entire solution. Can anyone provide me good solution that would help me in implementing the same??
Thanks in advance...
Posted
Updated 18-Aug-11 23:20pm
v2

1 solution

I would recommend creating an error handling component with optional logging available. The logging should be able to be turned on either through the config file, command line parameters or an options menu, depending on your target audience and how much you want to be involved.

Secondly, one solution I implemented when I was getting cryptic error messages returned was to create a stored procedure in SQL Server which queried a table for a user-friendly error message.

The table contained a user friendly error message and a error message pattern which would filter out factors like line number, etc.

The pattern would utilize the database wild card character for filtering messages. For example: :"%Order%not found%"

The meat of the stored procedure is:

SQL
SET @RtnMsg = (SELECT TOP 1 SFCErrorMessage FROM SAPErrorMsg WHERE  @Message LIKE  SAPPattern)

SET @RtnMsg = IsNull(@RtnMsg , @Message)


Finally, I am sure that you are aware that you can supply a default error handler in your application in the App.xaml.cs (or App.xaml.vb) file. I would urge you to only use this for unhandled errors and not as the default.

At a minimum, include the following code:

C#
private void APP_DispatcherUnhandledException(object sender,
    DispatcherUnhandledExceptionEventArgs e)
{
    MessageBox.Show(e.Exception.Message);
    e.Handled = true;
}


Hope that helps,
Ray
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900