CFx SDK Documentation
2023 SP0
SDK
CFx
dd_inc
DrxError.h
Go to the documentation of this file.
1
// Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3
// All rights reserved.
4
//
5
// This software and its documentation and related materials are owned by
6
// the Alliance. The software may only be incorporated into application
7
// programs owned by members of the Alliance, subject to a signed
8
// Membership Agreement and Supplemental Software License Agreement with the
9
// Alliance. The structure and organization of this software are the valuable
10
// trade secrets of the Alliance and its suppliers. The software is also
11
// protected by copyright law and international treaty provisions. Application
12
// programs incorporating this software must include the following statement
13
// with their copyright notices:
14
//
15
// This application incorporates Teigha(R) software pursuant to a license
16
// agreement with Open Design Alliance.
17
// Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18
// All rights reserved.
19
//
20
// By use of this software, its documentation or related materials, you
21
// acknowledge and accept the above terms.
23
24
#ifndef _TxError_h_Included_
25
#define _TxError_h_Included_
26
27
28
#include "
OdError.h
"
29
#include "
OdErrorContext.h
"
30
31
#include "
TD_PackPush.h
"
32
33
34
40
class
TxErrorContext
:
public
OdErrorContext
41
{
42
OdString
m_strAppName;
43
int
m_nAppErrCode;
44
OdString
m_strDescription;
45
46
public
:
47
TxErrorContext
()
48
: m_strAppName(L
"Unknown"
)
49
, m_nAppErrCode(0)
50
{}
51
52
53
OdSmartPtr<OdErrorContext>
init
(
const
OdString
&
name
,
int
nCode,
const
OdString
&
desc
=
OdString::kEmpty
)
54
{
55
m_strAppName =
name
;
56
m_nAppErrCode = nCode;
57
m_strDescription =
desc
;
58
return
this
;
59
}
60
61
67
OdString
description
()
const
68
{
69
if
(!m_strDescription.
isEmpty
())
70
return
m_strDescription;
71
else
72
return
OdString
().
format
(L
"Tx application \"%ls\" error: %d"
, m_strAppName.
c_str
(), m_nAppErrCode);
73
}
74
75
virtual
OdResult
code
()
const
{
return
eTxError; }
76
virtual
int
txAppCode
()
const
{
return
m_nAppErrCode; }
77
virtual
OdString
txAppName
()
const
{
return
m_strAppName;}
78
};
79
80
81
92
class
TxError
:
public
OdError
93
{
94
protected
:
95
TxError
(
OdErrorContext
* pCtx ) :
OdError
( pCtx )
96
{}
97
public
:
101
TxError
(
const
OdString
& sAppName,
int
nCode,
const
OdString
& desc =
OdString::kEmpty
)
102
:
OdError
(
OdRxObjectImpl
<
TxErrorContext
>::createObject()->
103
init(sAppName, nCode, desc))
104
{}
105
106
OdString
txAppName
()
const
107
{
108
return
((
TxErrorContext
*)
context
())->txAppName();
109
}
110
111
int
txAppCode
()
const
112
{
113
return
((
TxErrorContext
*)
context
())->txAppCode();
114
}
115
};
116
117
118
// Usage example:
119
/*
120
class MyAppError : public TxError
121
{
122
public:
123
MyAppError(int nCode) : TxError(L"MyApplication", nCode)
124
{}
125
};
126
127
128
pHostAppservices->warning(MyAppError(123));
129
or
130
throw(MyAppError(123));
131
*/
132
133
134
#include "
TD_PackPop.h
"
135
136
#endif
OdError.h
OdErrorContext.h
OdResult
OdResult
Definition:
OdResult.h:29
OdString
OdString OdString
Definition:
OdString.h:1224
TD_PackPop.h
TD_PackPush.h
OdErrorContext
Definition:
OdErrorContext.h:44
OdError
Definition:
OdError.h:43
OdError::context
const OdErrorContext * context() const
OdRxObject::desc
static OdRxClass * desc()
OdRxObjectImpl
Definition:
RxObjectImpl.h:55
OdSmartPtr
Definition:
SmartPtr.h:58
OdString
Definition:
OdString.h:95
OdString::c_str
const OdChar * c_str() const
Definition:
OdString.h:200
OdString::isEmpty
bool isEmpty() const
Definition:
OdString.h:141
OdString::format
OdString & format(const OdChar *formatString,...)
OdString::kEmpty
FIRSTDLL_EXPORT_STATIC static const OdString kEmpty
Definition:
OdString.h:98
TxErrorContext
Definition:
DrxError.h:41
TxErrorContext::description
OdString description() const
Definition:
DrxError.h:67
TxErrorContext::init
OdSmartPtr< OdErrorContext > init(const OdString &name, int nCode, const OdString &desc=OdString::kEmpty)
Definition:
DrxError.h:53
TxErrorContext::code
virtual OdResult code() const
Definition:
DrxError.h:75
TxErrorContext::txAppCode
virtual int txAppCode() const
Definition:
DrxError.h:76
TxErrorContext::txAppName
virtual OdString txAppName() const
Definition:
DrxError.h:77
TxErrorContext::TxErrorContext
TxErrorContext()
Definition:
DrxError.h:47
TxError
Definition:
DrxError.h:93
TxError::txAppName
OdString txAppName() const
Definition:
DrxError.h:106
TxError::TxError
TxError(const OdString &sAppName, int nCode, const OdString &desc=OdString::kEmpty)
Definition:
DrxError.h:101
TxError::TxError
TxError(OdErrorContext *pCtx)
Definition:
DrxError.h:95
TxError::txAppCode
int txAppCode() const
Definition:
DrxError.h:111
name
GLuint const GLchar * name
Definition:
gles2_ext.h:265
Generated on Thu Feb 24 2022 15:09:28