1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
// ****************************************************************************
// Project: GUYMAGER
// ****************************************************************************
// Programmer: Guy Voncken
// Police Grand-Ducale
// Service de Police Judiciaire
// Section Nouvelles Technologies
// ****************************************************************************
// Module: Error handling utilities
// ****************************************************************************
// Copyright 2008, 2009, 2010, 2011 Guy Voncken
//
// This file is part of guymager.
//
// guymager is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// guymager is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with guymager. If not, see <http://www.gnu.org/licenses/>.
#ifndef __ERROR_H__
#define __ERROR_H__
// -----------------------
// Exit codes
// -----------------------
static const int EXIT_NO_ERROR = 0;
static const int EXIT_AUTOEXIT = 1;
static const int EXIT_INTERNAL_ERROR = 10;
static const int EXIT_QT_FATAL = 11;
static const int EXIT_SIGNAL_RECEIVED = 12;
// -----------------------
// Prototypes
// -----------------------
void ErrorExit (int ExitCode = EXIT_INTERNAL_ERROR);
void ErrorPopupExit (const char *pFileName, const char *pFunctionName, int LineNr, APIRET ec, const char *pMsg);
APIRET ErrorInit (void);
APIRET ErrorDeInit (void);
// -----------------------
// Error handling macros
// -----------------------
#define CHK_QT(Func) \
{ \
if (Func == 0) \
{ \
(void)ToolErrorCheck (__FFL__, ERROR_QT_UNSUCCESSFUL); \
return ERROR_QT_UNSUCCESSFUL; \
} \
}
#define CHK_QT_POPUP(Func) \
{ \
if (Func == 0) \
ErrorPopupExit (__FFL__, ERROR_QT_UNSUCCESSFUL, "Qt returned FALSE"); \
}
#define CHK_QT_EXIT(Func) \
{ \
if (Func == 0) \
{ \
(void)ToolErrorCheck (__FFL__, ERROR_QT_UNSUCCESSFUL); \
exit (EXIT_QT_FATAL); \
} \
}
#define CHK_EXIT(Func) \
{ \
APIRET ec; \
/*lint -save -e506 -e774 -e1551*/ \
if ((ec = Func) != NO_ERROR) \
{ \
(void)ToolErrorCheck (__FFL__, ec); \
ErrorExit (); \
} \
/*lint -restore */ \
}
#define CHK_EXIT_POPUP_MSG(Func,pMsg) \
/*lint -save -e506 -e774*/ /*Warning 506: Constant value Boolean; Info 774: Boolean within 'if' always evaluates to True */ \
{ \
APIRET ec; \
if ((ec = Func) != NO_ERROR) \
ErrorPopupExit (__FFL__, ec, pMsg); \
} \
/*lint -restore*/
#define CHK_EXIT_POPUP(Func) \
CHK_POPUP_MSG(Func,NULL) \
#define CHK_EXIT_POPUP_CONST(ec) \
ErrorPopupExit (__FFL__, ec, NULL);
#endif
|