CNLMath : Utilities : error_message
error_message
Gets the text of the error message from the last function called.
Synopsis
#include <imsl.h>
char *imsl_error_message()
Return Value
Returns the current error message.
Description
If the current error type is positive then the last error message set is returned. It does not matter if the error message was printed or not. The current error type is the number returned by imsl_error_type. If the current error type is zero then NULL is returned.
The returned string can be freed using imsl_free.
Example
This example retrieves the error message from a call to imsl_f_gamma with an illegal argument. Error stopping is turned off so that the example continues beyond the terminal error.
 
#include <imsl.h>
#include <stdio.h>
 
int main(void)
{
char *msg;
 
imsl_error_options(
IMSL_SET_STOP, IMSL_TERMINAL, 0,
0);
 
imsl_f_gamma(0.0);
msg = imsl_error_message();
printf("type = %d\ncode = %d\n", imsl_error_type(), imsl_error_code());
printf("msg = %s\n", msg);
}
Output
 
*** TERMINAL Error from imsl_f_gamma. The argument for the function can not
*** be zero.
 
type = 5
code = 9024
msg = The argument for the function can not be zero.