OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
except.cpp
Go to the documentation of this file.
1
//----------------------------------------------------------------------------
2
// ObjectComponents
3
// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4
//
5
/// \file
6
// OLE Exception classes
7
//----------------------------------------------------------------------------
8
#include <
ocf/pch.h
>
9
#include <
ocf/defs.h
>
10
#include <
ocf/oleutil.h
>
11
#include <
owl/string.h
>
12
13
14
namespace
ocf
{
15
16
using namespace
owl;
17
18
//
19
//
20
//
21
TXOle::~TXOle
()
22
{
23
}
24
25
//
26
//
27
//
28
TXOle
*
29
TXOle::Clone
()
30
{
31
return
new
TXOle
(*
this
);
32
}
33
34
//
35
//
36
//
37
void
38
TXOle::Throw
()
39
{
40
throw
*
this
;
41
}
42
43
//
44
//
45
//
46
void
47
TXOle::Check
(HRESULT hr, LPCTSTR msg)
48
{
49
if
(FAILED(hr))
50
Throw
(hr, msg);
51
}
52
53
//
54
//
55
//
56
void
57
TXOle::Check
(HRESULT hr)
58
{
59
Check
(hr, 0);
60
}
61
62
//
63
//
64
//
65
void
66
TXOle::Throw
(HRESULT hr, LPCTSTR msg)
67
{
68
int
msg_len = msg ?
static_cast<
int
>
(
_tcslen
(msg)) : 0;
69
TAPointer<_TCHAR>
buf(
new
_TCHAR[256 + msg_len]);
70
wsprintf(buf,
_T
(
"%s failed, "
), msg ? msg :
_T
(
"OLE call"
));
71
72
int
len =
static_cast<
int
>
(
_tcslen
(buf));
73
OleErrorFromCode
(hr, buf + len, 256 + msg_len - len - 2);
74
_tcscat
(buf,
_T
(
"."
));
75
76
WARN
(hr !=
HR_NOERROR
, buf);
77
throw
TXOle
((_TCHAR*)buf, hr);
78
}
79
80
//
81
//
82
//
83
void
84
TXOle::OleErrorFromCode
(HRESULT stat, LPTSTR buffer,
int
size)
85
{
86
owl::tstring
error =
TSystemMessage
(stat).SysMessage();
87
int
len =
static_cast<
int
>
(
_tcslen
(error.c_str()));
88
len = len > size ? len-1 : size-1;
89
_tcsncpy
(buffer,error.c_str(),len);
90
buffer[len] = 0;
91
}
92
93
}
// OCF namespace
94
95
//==============================================================================
96
97
WARN
#define WARN(condition, message)
Definition
checks.h:273
ocf::TXOle
OLE API related exception object.
Definition
except.h:33
ocf::TXOle::Check
static void Check(HRESULT stat, LPCTSTR msg)
Definition
except.cpp:47
ocf::TXOle::TXOle
TXOle(const owl::tstring &msg, HRESULT stat)
Definition
except.h:58
ocf::TXOle::OleErrorFromCode
static void OleErrorFromCode(HRESULT stat, TCHAR *buffer, int size)
Definition
except.cpp:84
ocf::TXOle::~TXOle
~TXOle()
Definition
except.cpp:21
ocf::TXOle::Throw
void Throw()
Definition
except.cpp:38
ocf::TXOle::Clone
TXOle * Clone()
Definition
except.cpp:29
owl::TAPointer
Pointer to an array of type T.
Definition
pointer.h:103
_tcscat
#define _tcscat
Definition
cygwin.h:83
_tcsncpy
#define _tcsncpy
Definition
cygwin.h:80
_tcslen
#define _tcslen
Definition
cygwin.h:74
owl::TSystemMessage::TSystemMessage
TSystemMessage()
default errorId, def language
Definition
module.cpp:91
pch.h
Include for OC, gets common headers when precompiled headers are enabled.
ocf
Object Component Framework (COM encapsulation).
Definition
appdesc.h:22
ocf::_T
_T("!ForeColor")
owl::tstring
std::string tstring
Definition
defs.h:79
defs.h
ObjectComponents fundamental definitions.
HR_NOERROR
#define HR_NOERROR
Definition
defs.h:73
oleutil.h
Low level OLE Utility class definitions.
string.h
Definition of class TString, a flexible universal string envelope class.
source
ocf
except.cpp
Generated by
1.18.0