Files
CoolProp/include/Exceptions.h
Julien Marrec 05c8cf503b Lint: use automated tooling to reformat C++ and CMakeLists files (#2103)
* Add initial clang tidy / clang format config files

* Clang format the entire codebase

```
find ./src -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./include -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./Web -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./dev -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./wrappers -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
```

* Add a .cmake-format file and reformat CmakeLists.txt with it

https://github.com/cheshirekow/cmake_format

* Add a clang-format workflow


only runs on PRs, only on touched files
2022-03-31 10:51:48 -04:00

76 lines
2.1 KiB
C++

#ifndef CPEXCEPTIONS_H
#define CPEXCEPTIONS_H
#include <exception>
#include <iostream>
namespace CoolProp {
class CoolPropBaseError : public std::exception
{
public:
enum ErrCode
{
eNotImplemented,
eSolution,
eAttribute,
eOutOfRange,
eValue,
eWrongFluid,
eComposition,
eInput,
eNotAvailable,
eHandle,
eKey,
eUnableToLoad,
eDirectorySize
};
CoolPropBaseError(const std::string& err, ErrCode code) throw() : m_code(code), m_err(err) {}
~CoolPropBaseError() throw(){};
virtual const char* what() const throw() {
return m_err.c_str();
}
ErrCode code() {
return m_code;
}
private:
ErrCode m_code;
std::string m_err;
};
template <CoolPropBaseError::ErrCode errcode>
class CoolPropError : public CoolPropBaseError
{
public:
CoolPropError(const std::string& err = "", ErrCode ecode = errcode) throw() : CoolPropBaseError(err, ecode) {}
};
typedef CoolPropError<CoolPropBaseError::eNotImplemented> NotImplementedError;
typedef CoolPropError<CoolPropBaseError::eSolution> SolutionError;
typedef CoolPropError<CoolPropBaseError::eAttribute> AttributeError;
typedef CoolPropError<CoolPropBaseError::eOutOfRange> OutOfRangeError;
typedef CoolPropError<CoolPropBaseError::eValue> ValueError;
typedef CoolPropError<CoolPropBaseError::eKey> KeyError;
typedef CoolPropError<CoolPropBaseError::eHandle> HandleError;
typedef CoolPropError<CoolPropBaseError::eUnableToLoad> UnableToLoadError;
typedef CoolPropError<CoolPropBaseError::eDirectorySize> DirectorySizeError;
// ValueError specializations
template <CoolPropBaseError::ErrCode errcode>
class ValueErrorSpec : public ValueError
{
public:
ValueErrorSpec(const std::string& err = "", ErrCode ecode = errcode) throw() : ValueError(err, ecode) {}
};
typedef ValueErrorSpec<CoolPropBaseError::eWrongFluid> WrongFluidError;
typedef ValueErrorSpec<CoolPropBaseError::eComposition> CompositionError;
typedef ValueErrorSpec<CoolPropBaseError::eInput> InputError;
typedef ValueErrorSpec<CoolPropBaseError::eNotAvailable> NotAvailableError;
}; /* namespace CoolProp */
#endif