1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
1 |
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
|
2 |
*
|
|
3 |
* PrimeBase Media Stream for MySQL
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
8 |
* (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
18 |
*
|
19 |
* Original author: Paul McCullagh (H&G2JCtL)
|
|
20 |
* Continued development: Barry Leslie
|
|
21 |
*
|
|
22 |
* 2007-05-20
|
|
23 |
*
|
|
24 |
* The root of all exceptions.
|
|
25 |
*
|
|
26 |
*/
|
|
27 |
||
28 |
#ifndef __CSEXEPTION_H__
|
|
29 |
#define __CSEXEPTION_H__
|
|
30 |
||
31 |
#include <errno.h> |
|
32 |
#include <limits.h> |
|
33 |
||
34 |
#include "CSDefs.h" |
|
35 |
#include "CSString.h" |
|
36 |
#include "CSObject.h" |
|
37 |
||
38 |
using namespace std; |
|
39 |
||
40 |
#define CS_ERR_ASSERTION -14000
|
|
41 |
#define CS_ERR_EOF -14001
|
|
42 |
#define CS_ERR_JUMP_OVERFLOW -14002
|
|
43 |
#define CS_ERR_BAD_ADDRESS -14003
|
|
44 |
#define CS_ERR_UNKNOWN_SERVICE -14004
|
|
45 |
#define CS_ERR_UNKNOWN_HOST -14005
|
|
46 |
#define CS_ERR_UNKNOWN_METHOD -14006
|
|
47 |
#define CS_ERR_NO_LISTENER -14007
|
|
48 |
#define CS_ERR_GENERIC_ERROR -14008
|
|
49 |
#define CS_ERR_RELEASE_OVERFLOW -14009
|
|
50 |
#define CS_ERR_IMPL_MISSING -14010
|
|
51 |
#define CS_ERR_BAD_HEADER_MAGIC -14011
|
|
52 |
#define CS_ERR_VERSION_TOO_NEW -14012
|
|
53 |
#define CS_ERR_BAD_FILE_HEADER -14013
|
|
54 |
#define CS_ERR_BAD_HTTP_HEADER -14014
|
|
55 |
#define CS_ERR_INVALID_RECORD -14015
|
|
56 |
#define CS_ERR_CHECKSUM_ERROR -14016
|
|
57 |
#define CS_ERR_MISSING_HTTP_HEADER -14017
|
|
58 |
#define CS_ERR_OPERATION_NOT_SUPPORTED -14018
|
|
59 |
||
60 |
#define CS_EXC_CONTEXT_SIZE 300
|
|
61 |
#define CS_EXC_MESSAGE_SIZE (PATH_MAX + 300)
|
|
62 |
#define CS_EXC_DETAILS_SIZE (CS_EXC_CONTEXT_SIZE + CS_EXC_MESSAGE_SIZE)
|
|
63 |
||
64 |
class CSException : public CSObject { |
|
65 |
public: |
|
66 |
CSException() { |
|
67 |
iErrorCode = 0; |
|
68 |
iContext[0] = 0; |
|
69 |
iMessage[0] = 0; |
|
70 |
}
|
|
71 |
virtual ~CSException() { } |
|
72 |
||
73 |
void setErrorCode(int e) { iErrorCode = e; } |
|
1548.2.14
by Barry.Leslie at PrimeBase
Code cleanup. |
74 |
int getErrorCode() { return iErrorCode; } |
75 |
const char *getContext(){ return iContext; } |
|
76 |
const char *getMessage(){ return iMessage; } |
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
77 |
|
78 |
void setStackTrace(CSThread *self, const char *stack); |
|
79 |
void setStackTrace(CSThread *self); |
|
80 |
const char *getStackTrace(); |
|
81 |
||
82 |
void log(CSThread *self); |
|
83 |
void log(CSThread *self, const char *message); |
|
84 |
||
1548.2.11
by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser. |
85 |
void initException(CSException &exception); |
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
86 |
void initException(const char *func, const char *file, int line, int err, const char *message); |
87 |
void initAssertion(const char *func, const char *file, int line, const char *message); |
|
1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
88 |
void getCoreError(uint32_t size, char *buffer, int err); |
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
89 |
void initCoreError(const char *func, const char *file, int line, int err); |
90 |
void initCoreError(const char *func, const char *file, int line, int err, const char *item); |
|
91 |
void initOSError(const char *func, const char *file, int line, int err); |
|
92 |
void initFileError(const char *func, const char *file, int line, const char *path, int err); |
|
93 |
void initSignal(const char *func, const char *file, int line, int err); |
|
94 |
void initEOFError(const char *func, const char *file, int line, const char *path); |
|
95 |
||
96 |
static void RecordException(const char *func, const char *file, int line, int err, const char *message); |
|
97 |
static void ClearException(); |
|
98 |
||
99 |
static void throwException(const char *func, const char *file, int line, int err, const char *message, const char *stack); |
|
100 |
static void throwException(const char *func, const char *file, int line, int err, const char *message); |
|
101 |
static void throwAssertion(const char *func, const char *file, int line, const char *message); |
|
102 |
static void throwCoreError(const char *func, const char *file, int line, int err); |
|
103 |
static void throwCoreError(const char *func, const char *file, int line, int err, const char *item); |
|
104 |
static void throwOSError(const char *func, const char *file, int line, int err); |
|
105 |
static void throwFileError(const char *func, const char *file, int line, const char *path, int err); |
|
106 |
static void throwFileError(const char *func, const char *file, int line, CSString *path, int err); |
|
107 |
static void throwSignal(const char *func, const char *file, int line, int err); |
|
108 |
static void throwEOFError(const char *func, const char *file, int line, const char *path); |
|
109 |
static void throwLastError(const char *func, const char *file, int line); /* Throw the last OS error: */ |
|
110 |
||
111 |
static void logOSError(const char *func, const char *file, int line, int err); |
|
112 |
static void logOSError(CSThread *self, const char *func, const char *file, int line, int err); |
|
113 |
static void logException(const char *func, const char *file, int line, int err, const char *message); |
|
114 |
||
115 |
private: |
|
116 |
||
117 |
int iErrorCode; |
|
118 |
char iContext[CS_EXC_CONTEXT_SIZE]; /* func(file:line) */ |
|
119 |
char iMessage[CS_EXC_MESSAGE_SIZE]; /* The actual message of the error. */ |
|
120 |
CSStringBuffer iStackTrace; |
|
121 |
};
|
|
122 |
||
123 |
#endif
|