Skip to content
Advertisement

Way to suppress PostgreSQL-Error with custom error

For the last hours I got stuck on the problem, that I want a custom error (“Wrong airline_id. Please check your input again”) over the normal error code (insert or update on table “flightplan” violates foreign key constraint “fk_flightplan_airline”).

But no matter what I try, I always get the standard error. Please Help.

Advertisement

Answer

The custom exceptions should be thrown before performing the insert so that the insert will not be executed:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement