Hi,

Iīve had the same problem some time ago and I did the following:

1. First of all, I try to catch all possible exceptions BEFORE executing the query, not nulls, field types, etc., with javascript and server side checks.
2. For those errors that cannot be predicted, there is a DBMS table simply whith the primary key being the "$h->errstr" strings, and a text field is my "beatifull" message to the user.
3. All data is cached on a BerkeleyDB and tied at run time.
4. When any query is executed, it looks for the "$h->errstr" key on the Cache and, if it finds, it is substituted by that message. If it is not, I use de DB errstr.

The thing I found good in this solution is that I can have different and specific error messages for the same kind of error in different tables/fields. For example, a primaty key violation in two different tables may have different messages.

The bad thing is that these error messages become very table/project specific, non portable between event different tables/DBMS, etc. But, in my case, itīs better this way, because if my end users dont undestand the message, they pick up the phone and call me several times a day. So, the messages I write are VERY meaningfull, well explained...

Diego de Lima

In reply to Re: Mapping database errors to user errors by Anonymous Monk
in thread Mapping database errors to user errors by jplindstrom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.