DCL 3.7.4
Loading...
Searching...
No Matches
SQLException.cpp File Reference
#include <dcl/Config.h>
#include <dcl/Object.h>
#include <dcl/Charset.h>
#include <dcl/Thread.h>
#include <dcl/SQL.h>

Go to the source code of this file.

Functions

__DCL_BEGIN_NAMESPACE IMPLEMENT_CLASSINFO (SQLException, Exception) String SQLException

Function Documentation

◆ IMPLEMENT_CLASSINFO()

__DCL_BEGIN_NAMESPACE IMPLEMENT_CLASSINFO ( SQLException ,
Exception  )

Definition at line 25 of file SQLException.cpp.

28{
29 StringBuilder r;
30#ifdef __DCL_DEBUG
31 if (_connHandle->errorFileName()) {
32 r = _connHandle->errorFileName();
33 r += __T(":");
34 r += Int32::toString(_connHandle->errorLine(), 10) + __T(": ");
35 }
36#endif
37
38 if (_connHandle->errorCode() == SQL::eServerError) {
39 r += _connHandle->serverTitle();
40 r += __T(": ");
41
42 ByteString s;
43 size_t n = 1024;
44 ByteBuffer* buf = ByteBuffer::create(n);
45 bool b = _connHandle->getErrorMessage(buf->data(), &n);
46 if (b) {
47 buf->__dataLength = n;
48 s = buf;
49 }
50 buf->release();
51
52 if (s.length() > 0) {
53 try {
54 r += UTF8Decoder::decode(s);
55 }
56 catch (CharsetConvertException* _e) {
57 __DCL_TRACE1(L"Warning!! getServerMessage [%ls]\n", _e->toString().data());
58 _e->destroy();
59 }
60 }
61 else {
62 r += __T("The Server Error Message is unavailable!!");
63 }
64 }
65 else {
66 r += __T("DCL: ");
67 size_t n = 256;
68 CharBuffer* buf = CharBuffer::create_e(n);
69 if (!SQL::getErrorMessage(buf->data(), &n, _connHandle->errorCode())) {
70 if (buf->__allocLength < n) {
71 CharBuffer::extend(buf, n);
72 }
73 SQL::getErrorMessage(buf->data(), &n, _connHandle->errorCode());
74 }
75 r.append(buf->data(), n);
76 buf->release();
77 }
78 return r;
79}
IOException *size_t r
Definition MediaInfo.cpp:82
#define __DCL_TRACE1(fmt, arg1)
Definition Object.h:399
#define __T(str)
Definition Object.h:60
virtual void destroy()
Definition Exception.cpp:74
String toString(unsigned _base=10) const
Definition Numeric.inl:93
@ eServerError
Definition SQLCore.h:21
static bool getErrorMessage(wchar_t *_buf, size_t *_buflen, Error _errorCode)
Definition SQLCore.cpp:38