T
Todd Scott
Does anyone have a suggestion on how to present error
messages in a "user-friendly" way. I know how to "handle"
exceptions but what I want to do (at a minimum) is present
useful feedback to the user rather than a cryptic,
technical looking error message. For instance, if I
update a table (using SQLDataAdapter.UPDATE()) and it
returns a "Violation of UNIQUE KEY constraint..." message
I want to tell the user:
"User name entered already selected. Please select
another"
and not:
"Violation of UNIQUE KEY
constraint 'IX_Customer_Duplicate_User_Name'. Cannot
insert duplicate key in object 'Customer'.Source: .Net
SqlClient Data Provider"
I can not find a way to find out what constraint was
violated or what columns caused the error. I guess I
could parse the error message and then "hard-code" a
switch statement but that is not very "scalable"
or "object oriented".
Any suggestions?
messages in a "user-friendly" way. I know how to "handle"
exceptions but what I want to do (at a minimum) is present
useful feedback to the user rather than a cryptic,
technical looking error message. For instance, if I
update a table (using SQLDataAdapter.UPDATE()) and it
returns a "Violation of UNIQUE KEY constraint..." message
I want to tell the user:
"User name entered already selected. Please select
another"
and not:
"Violation of UNIQUE KEY
constraint 'IX_Customer_Duplicate_User_Name'. Cannot
insert duplicate key in object 'Customer'.Source: .Net
SqlClient Data Provider"
I can not find a way to find out what constraint was
violated or what columns caused the error. I guess I
could parse the error message and then "hard-code" a
switch statement but that is not very "scalable"
or "object oriented".
Any suggestions?