diff options
Diffstat (limited to '')
-rw-r--r-- | src/exception.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/exception.cpp b/src/exception.cpp index 11f04a9..291a198 100644 --- a/src/exception.cpp +++ b/src/exception.cpp | |||
@@ -5,12 +5,9 @@ Exception::Exception( const char *lpFormat, ... ) throw() : | |||
5 | nErrorCode( 0 ) | 5 | nErrorCode( 0 ) |
6 | { | 6 | { |
7 | va_list ap; | 7 | va_list ap; |
8 | int nSize; | ||
9 | 8 | ||
10 | va_start(ap, lpFormat); | 9 | va_start(ap, lpFormat); |
11 | nSize = vsnprintf( NULL, 0, lpFormat, ap ); | 10 | setWhat( lpFormat, ap ); |
12 | sWhat = new char[nSize+1]; | ||
13 | vsnprintf( sWhat, nSize+1, lpFormat, ap ); | ||
14 | va_end(ap); | 11 | va_end(ap); |
15 | } | 12 | } |
16 | 13 | ||
@@ -18,20 +15,32 @@ Exception::Exception( int nCode, const char *lpFormat, ... ) throw() : | |||
18 | nErrorCode( nCode ) | 15 | nErrorCode( nCode ) |
19 | { | 16 | { |
20 | va_list ap; | 17 | va_list ap; |
21 | int nSize; | ||
22 | 18 | ||
23 | va_start(ap, lpFormat); | 19 | va_start(ap, lpFormat); |
24 | nSize = vsnprintf( NULL, 0, lpFormat, ap ); | 20 | setWhat( lpFormat, ap ); |
25 | sWhat = new char[nSize+1]; | ||
26 | vsnprintf( sWhat, nSize+1, lpFormat, ap ); | ||
27 | va_end(ap); | 21 | va_end(ap); |
28 | } | 22 | } |
29 | 23 | ||
24 | Exception::Exception( int nCode ) throw() : | ||
25 | nErrorCode( nCode ), | ||
26 | sWhat( NULL ) | ||
27 | { | ||
28 | } | ||
29 | |||
30 | Exception::~Exception() throw() | 30 | Exception::~Exception() throw() |
31 | { | 31 | { |
32 | delete[] sWhat; | 32 | delete[] sWhat; |
33 | } | 33 | } |
34 | 34 | ||
35 | void Exception::setWhat( const char *lpFormat, va_list &vargs ) | ||
36 | { | ||
37 | int nSize; | ||
38 | |||
39 | nSize = vsnprintf( NULL, 0, lpFormat, vargs ); | ||
40 | sWhat = new char[nSize+1]; | ||
41 | vsnprintf( sWhat, nSize+1, lpFormat, vargs ); | ||
42 | } | ||
43 | |||
35 | const char *Exception::what() const throw() | 44 | const char *Exception::what() const throw() |
36 | { | 45 | { |
37 | return sWhat; | 46 | return sWhat; |