1 /* 2 * Copyright (C) 1996-2011 Daniel Waggoner 3 * 4 * This free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * It is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * If you did not received a copy of the GNU General Public License 15 * with this software, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef __ERROR_HANDLING__ 19 #define __ERROR_HANDLING__ 20 21 #include <stdio.h> 22 23 #ifdef __cplusplus 24 extern "C" 25 { 26 #endif 27 28 #define NO_ERR 0x00000000 29 #define ALL_ERRORS 0x000F0FFF 30 31 //=== General Errors === Default message 32 #define MEM_ERR 0x00000001 // Out of memory. 33 #define FILE_ERR 0x00000002 // File operation error. 34 #define PARSE_ERR 0x00000004 // Error parsing data. 35 #define FLOAT_ERR 0x00000008 // Floating point error. 36 #define NULL_ERR 0x00000010 // Unexpected null pointer encountered. 37 #define ARG_ERR 0x00000020 // Argument error. 38 #define ITERATION_ERR 0x00000040 // Maximum iteration limit exceeded. 39 #define USER_ERR 0x00000080 // Undocumented error. 40 #define NOT_IMPLEMENTED_ERR 0x00000100 // Feature not yet implemented. 41 #define UNKNOWN_ERR 0x00000200 // Unknown error. 42 #define FILE_OPEN_ERR 0x00000400 // Unable to open/create file. 43 #define FILE_READ_WRITE_ERR 0x00000800 // Unable to read/write to file. 44 45 //=== Matrix Errors === 46 #define SIZE_ERR 0x00010000 // Matrices/vectors not conformable. 47 #define SING_ERR 0x00020000 // Singular matrix. 48 #define POSDEF_ERR 0x00040000 // Matrix not positive definite. 49 #define BLAS_LAPACK_ERR 0x00080000 // Blas/Lapack error. 50 51 //=== Error Routines === 52 int dw_GetError(void); 53 char* dw_GetErrorMessage(void); 54 int dw_ClearError(void); 55 int dw_SetError(int err, char *msg); 56 int dw_Error(int err); 57 int dw_UserError(char *msg); 58 int dw_FileError(int err, char *filename); 59 int dw_SetVerboseErrors(int errors); 60 int dw_GetVerboseErrors(void); 61 int dw_SetTerminalErrors(int errors); 62 int dw_GetTerminalErrors(void); 63 int dw_CreateErrorMessageFile(char *filename); 64 int dw_AppendErrorMessageFile(char *filename); 65 void dw_ConsoleErrorMessage(void); 66 FILE* dw_GetErrorFilePointer(void); 67 char* dw_GetErrorFilename(void); 68 69 #ifdef __cplusplus 70 } 71 #endif 72 73 #endif 74