diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
commit | 469bbcf0701e1eb8a6670c23145b0da87357e178 (patch) | |
tree | b5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/exceptionbase.cpp | |
parent | ee1b79396076edc4e30aefb285fada03bb45e80d (diff) | |
download | libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2 libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip |
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/exceptionbase.cpp')
-rw-r--r-- | src/exceptionbase.cpp | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/src/exceptionbase.cpp b/src/exceptionbase.cpp deleted file mode 100644 index 13a98db..0000000 --- a/src/exceptionbase.cpp +++ /dev/null | |||
@@ -1,93 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/exceptionbase.h" | ||
9 | #include <stdarg.h> | ||
10 | #include <string.h> | ||
11 | #include <stdio.h> | ||
12 | |||
13 | Bu::ExceptionBase::ExceptionBase( const char *lpFormat, ... ) throw() : | ||
14 | nErrorCode( 0 ), | ||
15 | sWhat( NULL ) | ||
16 | { | ||
17 | va_list ap; | ||
18 | |||
19 | va_start(ap, lpFormat); | ||
20 | setWhat( lpFormat, ap ); | ||
21 | va_end(ap); | ||
22 | } | ||
23 | |||
24 | Bu::ExceptionBase::ExceptionBase( int nCode, const char *lpFormat, ... ) throw() : | ||
25 | nErrorCode( nCode ), | ||
26 | sWhat( NULL ) | ||
27 | { | ||
28 | va_list ap; | ||
29 | |||
30 | va_start(ap, lpFormat); | ||
31 | setWhat( lpFormat, ap ); | ||
32 | va_end(ap); | ||
33 | } | ||
34 | |||
35 | Bu::ExceptionBase::ExceptionBase( int nCode ) throw() : | ||
36 | nErrorCode( nCode ), | ||
37 | sWhat( NULL ) | ||
38 | { | ||
39 | } | ||
40 | |||
41 | Bu::ExceptionBase::ExceptionBase( const ExceptionBase &e ) throw () : | ||
42 | std::exception( e ), | ||
43 | nErrorCode( e.nErrorCode ), | ||
44 | sWhat( NULL ) | ||
45 | { | ||
46 | setWhat( e.sWhat ); | ||
47 | } | ||
48 | |||
49 | Bu::ExceptionBase::~ExceptionBase() throw() | ||
50 | { | ||
51 | delete[] sWhat; | ||
52 | sWhat = NULL; | ||
53 | } | ||
54 | |||
55 | void Bu::ExceptionBase::setWhat( const char *lpFormat, va_list &vargs ) | ||
56 | { | ||
57 | if( sWhat ) delete[] sWhat; | ||
58 | int nSize; | ||
59 | |||
60 | va_list vargs2; | ||
61 | va_copy( vargs2, vargs ); | ||
62 | nSize = vsnprintf( NULL, 0, lpFormat, vargs2 ); | ||
63 | va_end( vargs2 ); | ||
64 | sWhat = new char[nSize+1]; | ||
65 | vsnprintf( sWhat, nSize+1, lpFormat, vargs ); | ||
66 | } | ||
67 | |||
68 | void Bu::ExceptionBase::setWhat( const char *lpText ) | ||
69 | { | ||
70 | if( sWhat ) delete[] sWhat; | ||
71 | int nSize; | ||
72 | |||
73 | nSize = strlen( lpText ); | ||
74 | sWhat = new char[nSize+1]; | ||
75 | strcpy( sWhat, lpText ); | ||
76 | } | ||
77 | |||
78 | const char *Bu::ExceptionBase::what() const throw() | ||
79 | { | ||
80 | return sWhat; | ||
81 | } | ||
82 | |||
83 | int Bu::ExceptionBase::getErrorCode() | ||
84 | { | ||
85 | return nErrorCode; | ||
86 | } | ||
87 | |||
88 | Bu::UnsupportedException::UnsupportedException() throw() : | ||
89 | ExceptionBase( 0 ) | ||
90 | { | ||
91 | setWhat("An unsupperted operation was attempted."); | ||
92 | } | ||
93 | |||