diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-12-16 16:03:22 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2023-01-03 19:21:04 -0500 |
| commit | 5088ccdc46c37db4cd95574575b8afd83113f839 (patch) | |
| tree | 98edeb400b9a1072380a3c811705d0dd6e4efef3 /rapidjsonwrapper.h | |
| parent | d7bbc44a12c3ba51568675412708d0efaf29d978 (diff) | |
Use file/line numbers in rapidjson generic errors
Diffstat (limited to 'rapidjsonwrapper.h')
| -rw-r--r-- | rapidjsonwrapper.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/rapidjsonwrapper.h b/rapidjsonwrapper.h index e12465d6..a6775857 100644 --- a/rapidjsonwrapper.h +++ b/rapidjsonwrapper.h @@ -13,8 +13,12 @@ struct ParseException; struct GenericException : public std::exception { - GenericException() : std::exception() {} - virtual const char* what() const throw() { return "Exception while parsing json."; } + char text[0x200]; + GenericException(const char* file, int line, const char* description) : std::exception() { + snprintf(text, sizeof(text), "%s:%d: %s", file, line, description); + } + virtual const char* what() const throw() + { return text; } }; #define RAPIDJSON_HAS_STDSTRING 0 @@ -23,7 +27,7 @@ struct GenericException : public std::exception do \ { \ if (!(x)) \ - throw GenericException(); \ + throw GenericException(__FILE__, __LINE__, #x); \ } while (0); #define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset) \ throw ParseException(parseErrorCode, #parseErrorCode, offset) |
