summaryrefslogtreecommitdiff
path: root/rapidjsonwrapper.h
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2022-12-16 16:03:22 -0500
committerGlenn Smith <glenn@vector35.com>2023-01-03 19:21:04 -0500
commit5088ccdc46c37db4cd95574575b8afd83113f839 (patch)
tree98edeb400b9a1072380a3c811705d0dd6e4efef3 /rapidjsonwrapper.h
parentd7bbc44a12c3ba51568675412708d0efaf29d978 (diff)
Use file/line numbers in rapidjson generic errors
Diffstat (limited to 'rapidjsonwrapper.h')
-rw-r--r--rapidjsonwrapper.h10
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)