refactor(exceptions): All exceptions are derived from GridFireError

Now all GridFire exceptions are derived from the base GridFireError,
this allows for more clean handling of various exception cases
This commit is contained in:
2025-11-21 14:26:24 -05:00
parent 442d4ed86c
commit acc71ba12e
20 changed files with 89 additions and 201 deletions

View File

@@ -1,22 +1,10 @@
#pragma once
#include <exception>
#include <string>
#include "gridfire/exceptions/gridfire_exception.h"
namespace gridfire::exceptions {
class SolverError : public std::exception {
public:
SolverError(std::string msg) : m_msg(std::move(msg)) {}
[[nodiscard]] const char* what() const noexcept override {
return m_msg.c_str();
}
private:
std::string m_msg;
};
class CVODESolverFailureError final : public SolverError {
using SolverError::SolverError;
class SolverError : GridFireError {
using GridFireError::GridFireError;
};
class SingularJacobianError final : public SolverError {
@@ -26,4 +14,17 @@ namespace gridfire::exceptions {
class IllConditionedJacobianError final : public SolverError {
using SolverError::SolverError;
};
class SUNDIALSError : public SolverError {
using SolverError::SolverError;
};
class CVODESolverFailureError final : public SUNDIALSError {
using SUNDIALSError::SUNDIALSError;
};
class KINSolSolverFailureError final : public SUNDIALSError {
using SUNDIALSError::SUNDIALSError;
};
}