DCL 4.0
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 24 of file SQLException.cpp.

27{
28 StringBuilder r;
29#ifdef __DCL_DEBUG
30 if (_connHandle->errorFileName())
31 {
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 {
40 r += _connHandle->serverTitle();
41 r += __T(": ");
42
43 ByteString s;
44 size_t n = 1024;
45 ByteBuffer* buf = ByteBuffer::create(n);
46 bool b = _connHandle->getErrorMessage(buf->data(), &n);
47 if (b) {
48 buf->__dataLength = n;
49 s = buf;
50 }
51 buf->release();
52
53 if (s.length() > 0) {
54 try {
55 r += UTF8Decoder::decode(s);
56 }
57 catch (CharsetConvertException* e) {
58 // __DCL_TRACE_E(e);
59 e->destroy();
60 }
61 }
62 else {
63 r += __T("The Server Error Message is unavailable!!");
64 }
65 }
66 else {
67 r += __T("DCL: ");
68 size_t n = 256;
69 CharBuffer* buf = CharBuffer::create_e(n);
70 if (!SQL::getErrorMessage(buf->data(), &n, _connHandle->errorCode()))
71 {
72 if (buf->__allocLength < n) {
73 CharBuffer::extend(buf, n);
74 }
75 SQL::getErrorMessage(buf->data(), &n, _connHandle->errorCode());
76 }
77 r.append(buf->data(), n);
78 buf->release();
79 }
80
81 return r;
82}
#define __T(str)
Definition Object.h:44
ByteString r
ByteBuffer * buf
void CharsetConvertException *size_t n
Definition SQLField.cpp:253
virtual void destroy()
Definition Exception.cpp:74
String toString(unsigned _base=10) const
Definition Numeric.inl:87
@ eServerError
Definition SQLCore.h:21
static bool getErrorMessage(wchar_t *_buf, size_t *_buflen, Error _errorCode)
Definition SQLCore.cpp:40