How to display an error message generated from MySQL

Hi, I have created a page for Signon that is based on a User table in MySQL. One of the fields is Email. In the underlying MySQL there is a unique index defined for the Email column of the User table.

When I create a User in the page with a new email, it creates perfectly. When I try again with the same email (which I do deliberately to check that the error will be caught), I get a 500 notification, but the text of the error reason for the 500 is not displayed.

In Inspect in Chrome, the problem is clearly indicated.

How do I get the MySQL error to be displayed in an Alert or some such, so that the user has a clue as to what to do about the error that has been caused.

I realize that this error is easily trapped with a Exists validation, so this question is just used as an example of how to handle unanticipated errors from MySQL.

Community Page
Last updated: