packages/engine/scram-node/src/error.h
Exceptions for SCRAM. More...
Namespaces
| Name |
|---|
| scram |
| scram::mef |
| scram::xml |
Classes
| Name | |
|---|---|
| class | scram::Error <br>The Error class is the base class for all exceptions specific to the SCRAM code. |
| struct | scram::IOError <br>For input/output related errors. |
| struct | scram::DLError <br>Dynamic library errors. |
| struct | scram::LogicError <br>Signals internal logic errors, for example, pre-condition failure or use of functionality in ways not designed to. |
| struct | scram::IllegalOperation <br>This error can be used to indicate that call for a function or operation is not legal. |
| struct | scram::SettingsError <br>The error in analysis settings. |
| struct | scram::VersionError <br>The minimum required version is not satisfied. |
| struct | scram::mef::ValidityError <br>Model validity errors. |
| struct | scram::mef::DuplicateElementError <br>This error indicates that elements must be unique. |
| struct | scram::mef::UndefinedElement <br>The error for undefined elements in a model. |
| struct | scram::mef::CycleError <br>Unacceptable cycles in model structures. |
| struct | scram::mef::DomainError <br>Invalid domain for values or arguments. |
| struct | scram::xml::Error <br>The base for all XML related errors. |
| struct | scram::xml::ParseError <br>XML parsing errors. |
| struct | scram::xml::XIncludeError <br>XInclude resolution issues. |
| struct | scram::xml::ValidityError <br>XML document validity errors. |
Defines
| Name | |
|---|---|
| SCRAM_THROW(err) <br>Convenience macro to throw SCRAM exceptions. |
Detailed Description
Exceptions for SCRAM.
Exceptions are designed with boost::exception; that is, exception classes act like tags. No new data members shall ever be added to derived exception classes (no slicing upon copy or change of exception type!). Instead, all the data are carried with boost::error_info mechanism.
Macros Documentation
define SCRAM_THROW
cpp
#define SCRAM_THROW(
err
)
throw err << ::boost::throw_function(BOOST_CURRENT_FUNCTION) \
<< ::boost::throw_file(FILE_REL_PATH) \
<< ::boost::throw_line(__LINE__)Convenience macro to throw SCRAM exceptions.
Parameters:
- err The error type deriving from boost::exception.
This is similar to BOOST_THROW_EXCEPTION; however, it doesn't obfuscate the resultant exception type to conform to boost::exception.
Source code
cpp
/*
* Copyright (C) 2014-2018 Olzhas Rakhimov
* Copyright (C) 2023 OpenPRA ORG Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <exception>
#include <string>
#include <boost/current_function.hpp>
#include <boost/exception/exception.hpp>
#include <boost/exception/info.hpp>
#include <boost/exception/info_tuple.hpp>
#include "ext/source_info.h"
#define SCRAM_THROW(err) \
throw err << ::boost::throw_function(BOOST_CURRENT_FUNCTION) \
<< ::boost::throw_file(FILE_REL_PATH) \
<< ::boost::throw_line(__LINE__)
namespace scram {
using errinfo_value = boost::error_info<struct tag_value, std::string>;
class Error : virtual public std::exception, virtual public boost::exception {
public:
explicit Error(std::string msg) : msg_(std::move(msg)) {}
const char* what() const noexcept final { return msg_.c_str(); }
private:
std::string msg_;
};
struct IOError : public Error {
using Error::Error;
};
struct DLError : public Error {
using Error::Error;
};
struct LogicError : public Error {
using Error::Error;
};
struct IllegalOperation : public Error {
using Error::Error;
};
struct SettingsError : public Error {
using Error::Error;
};
struct VersionError : public Error {
using Error::Error;
};
namespace mef { // MEF specific errors.
using errinfo_container_id =
boost::error_info<struct tag_contianer_id, std::string>;
using errinfo_container_type =
boost::error_info<struct tag_container_type, const char*>;
using errinfo_container =
boost::tuple<errinfo_container_id, errinfo_container_type>;
using errinfo_attribute = boost::error_info<struct tag_attribute, std::string>;
using errinfo_element_id =
boost::error_info<struct tag_element_id, std::string>;
using errinfo_element_type =
boost::error_info<struct tag_element_type, const char*>;
using errinfo_element = boost::tuple<errinfo_element_id, errinfo_element_type>;
using errinfo_reference = boost::error_info<struct tag_reference, std::string>;
using errinfo_base_path = boost::error_info<struct tag_base_path, std::string>;
using errinfo_cycle = boost::error_info<struct tag_cycle, std::string>;
using errinfo_connective =
boost::error_info<struct tag_connective, std::string>;
struct ValidityError : public Error {
using Error::Error;
};
struct DuplicateElementError : public ValidityError {
DuplicateElementError() : ValidityError("Duplicate Element Error") {}
};
struct UndefinedElement : public ValidityError {
UndefinedElement() : ValidityError("Undefined Element Error") {}
};
struct CycleError : public ValidityError {
CycleError() : ValidityError("Cycle Error") {}
};
struct DomainError : public ValidityError {
using ValidityError::ValidityError;
};
} // namespace mef
namespace xml {
struct Error : public scram::Error {
using scram::Error::Error;
};
struct ParseError : public Error {
using Error::Error;
};
struct XIncludeError : public Error {
using Error::Error;
};
struct ValidityError : public Error {
using Error::Error;
};
using errinfo_attribute =
boost::error_info<struct tag_xml_attribute, std::string>;
using errinfo_element = boost::error_info<struct tag_xml_element, std::string>;
} // namespace xml
} // namespace scramUpdated on 2025-11-11 at 16:51:08 +0000
