Michael Hansen 10 years ago
parent
commit
6a46c98dea
  1. 11
      Sources/Plasma/CoreLib/hsExceptions.cpp
  2. 7
      Sources/Plasma/CoreLib/hsExceptions.h

11
Sources/Plasma/CoreLib/hsExceptions.cpp

@ -2,10 +2,9 @@
#include <cstring> #include <cstring>
const char *hsException::what() const HS_NOEXCEPT hsException::hsException(hsErrorEnum error, long param) HS_NOEXCEPT
: fError(error), fParam(param)
{ {
char buffer[64];
static const char *kErrorNames[] = { static const char *kErrorNames[] = {
"kNo_hsError", "kNo_hsError",
"kNilParam_hsError", "kNilParam_hsError",
@ -17,9 +16,7 @@ const char *hsException::what() const HS_NOEXCEPT
"kErrorNames not in sync with hsErrorEnum"); "kErrorNames not in sync with hsErrorEnum");
if (fError >= 0 && fError < hsErrorEnum_MAX) if (fError >= 0 && fError < hsErrorEnum_MAX)
snprintf(buffer, arrsize(buffer), "%s (%ld)", kErrorNames[fError], fParam); snprintf(fWhat, arrsize(fWhat), "%s (%ld)", kErrorNames[fError], fParam);
else else
snprintf(buffer, arrsize(buffer), "Unknown hsException error %d (%ld)", fError, fParam); snprintf(fWhat, arrsize(fWhat), "Unknown hsException error %d (%ld)", fError, fParam);
return buffer;
} }

7
Sources/Plasma/CoreLib/hsExceptions.h

@ -60,11 +60,10 @@ class hsException : public std::exception {
public: public:
hsErrorEnum fError; hsErrorEnum fError;
long fParam; long fParam;
char fWhat[64];
hsException(hsErrorEnum error, long param = 0) HS_NOEXCEPT hsException(hsErrorEnum error, long param = 0) HS_NOEXCEPT;
: fError(error), fParam(param) {} const char *what() const HS_NOEXCEPT HS_OVERRIDE { return fWhat; }
const char *what() const HS_NOEXCEPT HS_OVERRIDE;
}; };
class hsNilParamException : public hsException { class hsNilParamException : public hsException {

Loading…
Cancel
Save