diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-04-15 21:47:18 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-04-15 21:47:18 +0000 |
commit | 74eff8476459b02fd578da0227ae09fc957fae65 (patch) | |
tree | 9d669d2e2372e5ea83e7f5502e7b2791a778a508 /lib/common | |
parent | 324243fa90e199012a81bf08b232a9d523ce1fbf (diff) |
Add a static GetMessage() to get exception message for a known subtype code.
Diffstat (limited to 'lib/common')
-rwxr-xr-x | lib/common/makeexception.pl.in | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/lib/common/makeexception.pl.in b/lib/common/makeexception.pl.in index b1b3a8ac..e4018180 100755 --- a/lib/common/makeexception.pl.in +++ b/lib/common/makeexception.pl.in @@ -113,7 +113,7 @@ print H <<__E; { return mMessage; } - + static const char* GetMessage(int SubType); private: unsigned int mSubType; std::string mMessage; @@ -188,19 +188,43 @@ unsigned int ${class}Exception::GetSubType() const throw() return mSubType; } -const char *${class}Exception::what() const throw() +const char * ${class}Exception::what() const throw() { + std::string what = "${class}"; + #ifdef EXCEPTION_CODENAMES_EXTENDED - if(mSubType > (sizeof(whats) / sizeof(whats[0]))) + if(mSubType < (sizeof(whats) / sizeof(whats[0]))) { - return "${class}"; + what = whats[mSubType]; } - return whats[mSubType]; -#else - return "${class}"; #endif + + if(mMessage != "") + { + what += ": " + mMessage; + } + + return what.c_str(); +} + +const char * ${class}Exception::GetMessage(int SubType) +{ + switch(SubType) + { +__E + +for(my $e = 0; $e <= $#exception; $e++) +{ + if($exception[$e] ne '') + { + print CPP "\t\tcase ".$exception[$e].': return "'.$exception[$e].'";'."\n"; + } } +print CPP <<__E; + default: return "Unknown"; + } +} __E close H; |