Exemplo n.º 1
0
int ErrorHandler
(
    int fatal_flag,	/* I:  TRUE for fatal errors, FALSE otherwise */
    char *module,	/* I:  calling module name */
    int error_code,	/* I:  one of the #defined names in resample.h */
    char *extra_message		/* I:  extra info if needed */
)

{
    char error_msg[LARGE_STRING];	/* strings for constructing messages */
    char log_msg[HUGE_STRING];

    /* just in case someone is using a non-formal code */
    if ( error_code < 0 )
	error_code = -error_code;

    /* just in case someone calls us badly */
    if ( error_code >= NUM_ERROR_CODES )
	error_code = MRT_NO_ERROR;

    /* construct fatal string or a warning */
    if ( fatal_flag )
	sprintf( error_msg,
            "Error: %s : %s", module, formal_message[error_code] );
    else
	sprintf( error_msg,
            "Warning: %s : %s", module, formal_message[error_code] );

    /* construct message to the log file */
    if ( extra_message )
	sprintf( log_msg, "%s\n     : %s", error_msg, extra_message );
    else
	strcpy( log_msg, error_msg );

    /* log it */
    LogHandler( log_msg );

    /* print to terminal */
    fprintf( stdout, "%s\n", error_msg );
    fflush( stdout );

    /* extra to terminal ? */
    if ( extra_message )
    {
	fprintf( stdout, "     : %s\n", extra_message );
        fflush( stdout );
    }

    /* if its fatal, bail */
    if ( fatal_flag )
	AbortExit( error_code );

    return ( MRT_NO_ERROR );
}
Exemplo n.º 2
0
sc_status 
scError(
	sc_session session, sc_int error, const char* format, ...)
{
	sc_status status;
	sc_logging_info handle = scGetLoggingInfo(session, &status);
	sc_logging_info_t* log = handle ? (sc_logging_info_t*)handle : 0;

    va_list arg_list;
    va_start(arg_list, format);
	if(session == NULL || log == NULL)
	{
	    status = SystemLogHandler(SC_LOG_LEVEL_ERROR, error, format, arg_list);
	}
	else
	{
	    status = LogHandler(log, SC_LOG_LEVEL_ERROR, error, format, arg_list);
	}
    va_end(arg_list);
	return status;
}