#include <errcode.h>
Definition at line 71 of file errcode.h.
ERRCODE::ERRCODE | ( | const char * | string | ) | [inline] |
void ERRCODE::error | ( | const char * | caller, | |
INT8 | action, | |||
const char * | format, | |||
... | ||||
) | const |
Print an error message and continue, exit or abort according to action.
Makes use of error messages and numbers in a common place.
Definition at line 42 of file errcode.cpp.
References ABORT, BADERRACTION, DBG, err_exit(), error(), EXIT, FILE_ABORT, global_abort_code, LIST_ABORT, LOG, MAX_MSG, MEMORY_ABORT, message, NO_ABORT_CODE, NULL, and tprintf().
Referenced by add_event(), MEM_ALLOCATOR::alloc(), MEM_ALLOCATOR::alloc_p(), apply_boxes(), ELIST2::assign_to_sublist(), ELIST::assign_to_sublist(), CLIST::assign_to_sublist(), WERD::baseline_denormalise(), WERD::baseline_normalise_x(), WERD::blob_list(), IMAGE::bufread(), WERD::cblob_list(), MEM_ALLOCATOR::check(), IMAGE::check_legal_access(), check_legal_image_size(), check_path_legal(), check_struct(), choice_dump_tester(), compress_region_list(), compute_page_skew(), compute_row_stats(), IMAGE::convolver(), IMAGE::create(), ELIST_LINK::de_serialise_asc(), de_serialise_bytes(), de_serialise_FLOAT64(), de_serialise_INT32(), MEM_ALLOCATOR::dealloc(), delete_non_dropout_rows(), edges_and_textord(), error(), ELIST2_ITERATOR::exchange(), ELIST_ITERATOR::exchange(), CLIST_ITERATOR::exchange(), ELIST2_ITERATOR::extract_sublist(), ELIST_ITERATOR::extract_sublist(), CLIST_ITERATOR::extract_sublist(), find_band(), BLOCK_LINE_IT::get_line(), get_pd_vertex(), init_net(), init_tesseract(), kick_daemon(), main(), main_setup(), median_block_xheight(), name_to_image_type(), MEM_ALLOCATOR::new_block(), R_BITSTREAM::open(), open_outfile(), open_tif_image(), pgeditor_read_file(), pgeditor_write_file(), RADIO_MENU::press_radio_button(), IMAGE::read(), read_and_textord(), R_BITSTREAM::read_code(), IMAGE::read_header(), read_pd_file(), read_poly_blocks(), read_vec_file(), MENU_NODE::recalc_bounding_box(), WERD::rej_blob_list(), WERD::rej_cblob_list(), QLSQ::remove(), LLSQ::remove(), WERD::scale(), ELIST_LINK::serialise_asc(), serialise_bytes(), serialise_FLOAT64(), serialise_INT32(), start_variables_editor(), IMAGE::write(), W_BITSTREAM::write_code(), write_cooked_text(), write_map(), write_tif_image(), and write_unlv_text().
00047 { 00048 va_list args; //variable args 00049 char msg[MAX_MSG]; 00050 char *msgptr = msg; 00051 00052 if (caller != NULL) 00053 //name of caller 00054 msgptr += sprintf (msgptr, "%s:", caller); 00055 //actual message 00056 msgptr += sprintf (msgptr, "Error:%s", message); 00057 if (format != NULL) { 00058 msgptr += sprintf (msgptr, ":"); 00059 va_start(args, format); //variable list 00060 #ifdef __MSW32__ 00061 //print remainder 00062 msgptr += _vsnprintf (msgptr, MAX_MSG - 2 - (msgptr - msg), format, args); 00063 msg[MAX_MSG - 2] = '\0'; //ensure termination 00064 strcat (msg, "\n"); 00065 #else 00066 //print remainder 00067 msgptr += vsprintf (msgptr, format, args); 00068 //no specific 00069 msgptr += sprintf (msgptr, "\n"); 00070 #endif 00071 va_end(args); 00072 } 00073 else 00074 //no specific 00075 msgptr += sprintf (msgptr, "\n"); 00076 00077 tprintf(msg); 00078 if ((strstr (message, "File") != NULL) || 00079 (strstr (message, "file") != NULL)) 00080 global_abort_code = FILE_ABORT; 00081 else if ((strstr (message, "List") != NULL) || 00082 (strstr (message, "list") != NULL)) 00083 global_abort_code = LIST_ABORT; 00084 else if ((strstr (message, "Memory") != NULL) || 00085 (strstr (message, "memory") != NULL)) 00086 global_abort_code = MEMORY_ABORT; 00087 else 00088 global_abort_code = NO_ABORT_CODE; 00089 00090 switch (action) { 00091 case DBG: 00092 case LOG: 00093 return; //report only 00094 case EXIT: 00095 err_exit(); 00096 case ABORT: 00097 abort(); 00098 default: 00099 BADERRACTION.error ("error", ABORT, NULL); 00100 } 00101 }
const char* ERRCODE::message [private] |