File: error.h

package info (click to toggle)
guymager 0.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 932 kB
  • ctags: 1,580
  • sloc: cpp: 8,522; ansic: 2,571; makefile: 49; sh: 23
file content (99 lines) | stat: -rw-r--r-- 3,615 bytes parent folder | download
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
// ****************************************************************************
//  Project:        GUYMAGER
// ****************************************************************************
//  Programmer:     Guy Voncken
//                  Police Grand-Ducale
//                  Service de Police Judiciaire
//                  Section Nouvelles Technologies
// ****************************************************************************
//  Module:         Error handling utilities
// ****************************************************************************

#ifndef __ERROR_H__
#define __ERROR_H__

// -----------------------
//       Exit codes
// -----------------------

static const int EXIT_NO_ERROR        = 0;
static const int EXIT_INTERNAL_ERROR  = 1;
static const int EXIT_QT_FATAL        = 2;
static const int EXIT_SIGNAL_RECEIVED = 3;

// -----------------------
//      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