Expose loot-condition-interpreter error codes to callers

Make ConditionSyntaxError extend from system_error instead of directly from runtime_error, so that callers can use the exception's code to distinguish between different causes.
This commit is contained in:
Oliver Hamlet
2024-09-13 20:25:16 +01:00
parent 11f7f0415a
commit 6726532a40
4 changed files with 27 additions and 3 deletions
@@ -32,9 +32,9 @@ namespace loot {
* @brief An exception class thrown if invalid syntax is encountered when
* parsing a metadata condition.
*/
class ConditionSyntaxError : public std::runtime_error {
class ConditionSyntaxError : public std::system_error {
public:
using std::runtime_error::runtime_error;
using std::system_error::system_error;
};
}
@@ -45,6 +45,14 @@ LOOT_API const std::error_category& esplugin_category();
* derived from std::error_category.
*/
LOOT_API const std::error_category& libloadorder_category();
/**
* @brief Get the error category that can be used to identify system_error
* exceptions that are due to loot condition interpreter errors.
* @returns A reference to the static object of unspecified runtime type,
* derived from std::error_category.
*/
LOOT_API const std::error_category& loot_condition_interpreter_category();
}
#endif