Pass literal messages
To raise an exception whose message text you provide, the mi_db_error_raise() function requires a message type of MI_MESSAGE or MI_EXCEPTION and the associated message text.
When you pass the MI_MESSAGE or MI_EXCEPTION message type to the mi_db_error_raise() function,
the function raises an MI_Exception event whose error descriptor contains
the following information.
Error descriptor field | Warning | Runtime error |
---|---|---|
Exception level (2nd argument) | MI_MESSAGE | MI_EXCEPTION |
SQLSTATE value | "01U01" | "U0001" |
Message text (3rd argument) | Specified warning text | Specified error text |
For example, the following call to mi_db_error_raise() raises
an MI_Exception event with an exception level of MI_MESSAGE, an SQLSTATE value
of
01U01
, and the Operation Successful warning
message: mi_db_error_raise(conn, MI_MESSAGE, "Operation Successful");
For the following line, mi_db_error_raise() raises
an MI_Exception event with an exception level of MI_EXCEPTION, an SQLSTATE value
of
U0001
, and the Out of Memory!!! error
message: mi_db_error_raise(conn, MI_EXCEPTION, "Out of Memory!!!");
If any exception callback is registered for the same connection, the DataBlade® API sends this error descriptor to the callback when the MI_Exception event is raised.
If the C UDR (or any if its calling routines) has not registered
an exception callback when the MI_Exception event is raised, the DataBlade®
API performs
the default exception handling, which depends on the exception level
of the exception:
- If the exception has an MI_EXCEPTION exception level, the database server aborts the UDR and returns control to the calling module.
- If the exception has an MI_MESSAGE exception level, the database server sends the warning message to the calling module and continues execution of the UDR.
If the client LIBMI application has not registered an exception
callback when the MI_Exception event is raised, the client LIBMI calls
the system-default callback, which provides the following information:
- The connection
- The exception type: MI_MESSAGE or MI_EXCEPTION
- The message text that is associated with the exception