[ScottNeumann]
Most built-in RDBMS error messages are meant for techies, not end-users. However, there are generally a handful that are common to issues that the end-user can deal with. For example, take a duplicate name or key exception. Normally you check the existence first before performing the transaction. However, it is possible that an addition could have happened between short time that duplicates were checked and the time that the transaction is tried. Since we know such an error is possible under regular activity, we chould translate the message into into something for the end user.
if (x.ODBC_errCode == 2345) { raiseError("Duplicate record. That part number already exists."); }Another approach for a bigger shop is the have a table that translates error codes into English:
From To Description ----------------------- 2345 2345 "Duplicate record. That item already exists." 2501 2507 "The database or table is locked, probably for maintenance. Please try again later." 2745 2750 "Text or data is too long. Please inspect or your data."In some cases you may want it to display both the end-user version and the original to make phone support easier. Example:
---------------------- ERROR ---------------------- Duplicate record, That item already exists. ---------------------- TECHNICAL DETAILS: Error code: 2345 Constraint KDH-HDFL was violated during result set insertion on compound key value of.... ----------------------If the simplified version does not exist in the table, then display the technical version only (strait from the driver). It is also good to send the error to a log for later inspection such that the translation table can be improved.
Okay, that validated an assumption I made for myself. I've actually done all of above myself outside of having a table maintain error messages (have used a config file of name/value pairs which is really the same but different. ;))
But, what about the other two questions? Multiple Exceptions & Data Validation?
Curious. [ScottNeumann]