One way to do this is simply to do a query on that VIN first, before
trying to add the row. That way, there is no database error and you
can do what you like with the result. Good luck. Mark
On Mon, May 14, 2012 at 12:55 PM, Craig <
csa...@gmail.com> wrote:
> I have an input field in my component which takes a Vehicle Identification
> Number (VIN), and the database has a unique constraint on this field. If a
> user enters a duplicate VIN, I'd like to let the database throw its error,
> and then I can catch it and display a message to the user.
>
> Because this is a fatal error, I can't catch it - it is thrown as:
> JDatabaseMySQLi::query: 1062 - Duplicate entry
>
> With the call in Joomla's error.php:
> return JError::raise(E_ERROR, $code, $msg, $info, true);
>
> Is there a good way for me to do this? Normally, I'd like to let fatal
> errors get handled, but in this case I'd like to handle it myself because it
> isn't really fatal. I was thinking of storing the current error handler in a
> local variable, setting a new error handler that would do what I want right
> before my call to store(), and then replacing the original error handler
> afterwards. Or is there an easier way to do this?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
>
https://groups.google.com/d/msg/joomla-dev-general/-/6lIDPk2H8r4J.
> To post to this group, send an email to
joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
>
joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/joomla-dev-general?hl=en-GB.