[Info-ingres] User friendly error message on constraint violation

Roy Hann specially at processed.almost.meat
Wed Apr 8 08:10:26 UTC 2020


nikosv wrote:

> I have a check constraint that when fired displays "check integrity
> constraint violates "check_covid_test" on table test was violated"
> Now that doesn't help the user at all. Is there a way to catch it and
> instead display a nice user friendly error? Application is ABF/4GL. Or
> even in general how to handle such cases.

You are well ahead of the game by giving your constraint a relatively
user-friendly name.

The question is: who is the user? In the case of a data-integrity error
I would argue the user is the developer/support person. The application,
not the DBMS, is where the end-user experience should be defined. 

As a design principle I don't think end-user error reporting should be
pushed all the way down to the DBMS because--at least in principle--you
can't know what all future end-user applications will be.

If I had my way the application error handler would catch the error and
use the constraint name to decide what to report and how to report it.

You *could* implement your check constraint "by hand" using a rule fired
procedure but that would be more work and it would mean the constraint
could not be recognized as meta-data by any tool.  [Ha ha ha!!! Like
there are such tools! I know: "Pretty funny Roy. LMAO, tell us another."
But the principle is sound.]

Roy



More information about the Info-ingres mailing list