The SIGNAL statement is used to return an exception. A handler could potentially detect and act on exceptions defined by these statements.

SIGNAL SQLSTATE <sql_state> [SET <message_text> = <expression>]
sql_state
specifies the five-character SQLSTATE code. For example, HY000.
message_text
(optional) specifies the message to text to be returned when the exception is thrown.
expression
(optional) is the expression that is evaluated to determine whether the message text is returned.
Note: Default message text is provided by the SQLSTATE unless the expression of the SET command is met; however, this message might not be useful to your user. If the text provided by SQLSTATE is insufficient, you should provide your own message using the SET command.