-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDelayedException.h
More file actions
66 lines (47 loc) · 1.83 KB
/
Copy pathDelayedException.h
File metadata and controls
66 lines (47 loc) · 1.83 KB
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
// Copyright © 2006 CCP ehf.
/*
*************************************************************************
DelayedException.h
Project: EVE Server Database Access
Description:
Classes for working on the thread. No python stuff can happen here,
so we have to have special support to set up errors that will be
raised when python resumes.
Dependencies:
Python
*************************************************************************
*/
#ifndef DELAYEDEXCEPTION_H
#define DELAYEDEXCEPTION_H
//A delayed exception class. Use this to create python exceptions without actually
//creating them, since we cannot touch the python runtime in our worker thread.
//We have special static methods for handling the case when a new exception
//cannot be allocated, due to out of memory situations.
class DelayedException
{
private:
DelayedException(const char *msg, HRESULT hr, PyObject *cls);
public:
static DelayedException *New(HRESULT hr, const char *msg);
static DelayedException *New(PyObject *cls, const char *msg);
static DelayedException *New(const char *msg);
static DelayedException *NoMem(const char *fmt=0, ...);
static DelayedException *Dummy() {return reinterpret_cast<DelayedException*>(-1);}
void operator delete(void *p) throw();
bool Raise();
// is this an error we should drop the session because of?
bool IsSessionFatal() const;
public:
PyObject * const mCls;
const HRESULT mHR;
const std::string mMsg;
ULONG mNErrors;
CDBErrorInfo mErrorInfo;
std::shared_ptr<DelayedException> mNext;
};
typedef std::shared_ptr<DelayedException> DelayedException_ptr;
#define PYERROR(c, m) return DelayedException::New((c), (m))
#define PYDBERROR(m) PYERROR(Utilities::DbExc_RuntimeError, (m))
#define PYWARN(c, m) DelayedException::New((c), (m))
#define PYDBWARN(m) PYWARN(PyExc_UserWarning, (m))
#endif // DELAYEDEXCEPTION_H