summaryrefslogtreecommitdiff
path: root/src/exception.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-05-26 14:36:57 +0000
committerMike Buland <eichlan@xagasoft.com>2006-05-26 14:36:57 +0000
commita820665eea71a64b40e74ed24afeaf07a7a99db4 (patch)
tree515af31ac2ed78aa92ce7e90e478bdb452e6e438 /src/exception.cpp
parentbd5bb1ca60a6a97b110cbf221b3625e6e6200141 (diff)
downloadlibbu++-a820665eea71a64b40e74ed24afeaf07a7a99db4.tar.gz
libbu++-a820665eea71a64b40e74ed24afeaf07a7a99db4.tar.bz2
libbu++-a820665eea71a64b40e74ed24afeaf07a7a99db4.tar.xz
libbu++-a820665eea71a64b40e74ed24afeaf07a7a99db4.zip
Added the first of many unit tests. For now the unit tests are just built with
everything else in the all target of the makefile, which is fine, but relies on CppTest, which can be found at http://cpptest.sf.net Also fixed some things I've been meaning to get to for a while in the xml system, including a few bugs that will make coping with malformed data not hang other programs, and do the error reporting in a nice way.
Diffstat (limited to 'src/exception.cpp')
-rw-r--r--src/exception.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/exception.cpp b/src/exception.cpp
index 291a198..3cde134 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -2,7 +2,8 @@
2#include <stdarg.h> 2#include <stdarg.h>
3 3
4Exception::Exception( const char *lpFormat, ... ) throw() : 4Exception::Exception( const char *lpFormat, ... ) throw() :
5 nErrorCode( 0 ) 5 nErrorCode( 0 ),
6 sWhat( NULL )
6{ 7{
7 va_list ap; 8 va_list ap;
8 9
@@ -12,7 +13,8 @@ Exception::Exception( const char *lpFormat, ... ) throw() :
12} 13}
13 14
14Exception::Exception( int nCode, const char *lpFormat, ... ) throw() : 15Exception::Exception( int nCode, const char *lpFormat, ... ) throw() :
15 nErrorCode( nCode ) 16 nErrorCode( nCode ),
17 sWhat( NULL )
16{ 18{
17 va_list ap; 19 va_list ap;
18 20
@@ -29,11 +31,16 @@ Exception::Exception( int nCode ) throw() :
29 31
30Exception::~Exception() throw() 32Exception::~Exception() throw()
31{ 33{
32 delete[] sWhat; 34 if( sWhat )
35 {
36 delete[] sWhat;
37 sWhat = NULL;
38 }
33} 39}
34 40
35void Exception::setWhat( const char *lpFormat, va_list &vargs ) 41void Exception::setWhat( const char *lpFormat, va_list &vargs )
36{ 42{
43 if( sWhat ) delete[] sWhat;
37 int nSize; 44 int nSize;
38 45
39 nSize = vsnprintf( NULL, 0, lpFormat, vargs ); 46 nSize = vsnprintf( NULL, 0, lpFormat, vargs );