~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSException.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
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; }
 
74
        int getErrorCode() { return iErrorCode; }
 
75
        const char *getContext(){ return iContext; }
 
76
        const char *getMessage(){ return iMessage; }
 
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
 
 
85
        void initException(CSException &exception);
 
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);
 
88
        void getCoreError(uint32_t size, char *buffer, int err);
 
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