From 6a46c98dea07cdb86f6a2cee6fdc63373cf4fb9f Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sun, 2 Aug 2015 20:34:33 -0700 Subject: [PATCH] Fix derp --- Sources/Plasma/CoreLib/hsExceptions.cpp | 11 ++++------- Sources/Plasma/CoreLib/hsExceptions.h | 7 +++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsExceptions.cpp b/Sources/Plasma/CoreLib/hsExceptions.cpp index bb48e8b1..cbb81069 100644 --- a/Sources/Plasma/CoreLib/hsExceptions.cpp +++ b/Sources/Plasma/CoreLib/hsExceptions.cpp @@ -2,10 +2,9 @@ #include -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[] = { "kNo_hsError", "kNilParam_hsError", @@ -17,9 +16,7 @@ const char *hsException::what() const HS_NOEXCEPT "kErrorNames not in sync with hsErrorEnum"); 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 - snprintf(buffer, arrsize(buffer), "Unknown hsException error %d (%ld)", fError, fParam); - - return buffer; + snprintf(fWhat, arrsize(fWhat), "Unknown hsException error %d (%ld)", fError, fParam); } diff --git a/Sources/Plasma/CoreLib/hsExceptions.h b/Sources/Plasma/CoreLib/hsExceptions.h index 0265ecc0..47b5a525 100644 --- a/Sources/Plasma/CoreLib/hsExceptions.h +++ b/Sources/Plasma/CoreLib/hsExceptions.h @@ -60,11 +60,10 @@ class hsException : public std::exception { public: hsErrorEnum fError; long fParam; + char fWhat[64]; - hsException(hsErrorEnum error, long param = 0) HS_NOEXCEPT - : fError(error), fParam(param) {} - - const char *what() const HS_NOEXCEPT HS_OVERRIDE; + hsException(hsErrorEnum error, long param = 0) HS_NOEXCEPT; + const char *what() const HS_NOEXCEPT HS_OVERRIDE { return fWhat; } }; class hsNilParamException : public hsException {