My Design Goals. There are two cases when Further code of execution stops in that code block 1. When some run time error occurs 2. Based on some business logic
When there is an error it will throw exception and I dont want to show it to business user. But when there is some business logic error/Validation failure then I want user to know as he/she can fix it and proceed further.
Example
Type 01: unable to cast to string Exception
Type 02: No Data is present in system against this criteria.
Code Block:
//int for Error Code to distinguish type 01 errors and type 02 errors.
//message for Error message
public int generateReport(ref string Message)
{
try
{
//Fetch Data here
if(no data present)
{
throw new Exception("No Data Present in system against this criteria").
}
string message = dataTable;
}
}
So what is the best way for "Type 02 Exception" so that I will be able to communicate problem to user. And in case of "Type 01 Exception" I will simply say "Some Error Occured." and for developers/Support team I will show them exact reason for error without debugging facility they will be able to solve the problem.
try catchand display to the user a custom error message and log the e.Message or inner exception to the support team...?