Browse Source

Output exception type in exception message

tempestpy_adaptions
Matthias Volk 6 years ago
parent
commit
87cd72f237
  1. 13
      src/storm/exceptions/BaseException.cpp
  2. 10
      src/storm/exceptions/BaseException.h
  3. 3
      src/storm/exceptions/ExceptionMacros.h

13
src/storm/exceptions/BaseException.cpp

@ -19,8 +19,19 @@ namespace storm {
}
const char* BaseException::what() const NOEXCEPT {
errorString = this->stream.str();
errorString = this->type() + ": " + this->stream.str();
if (!this->additionalInfo().empty()) {
errorString += " " + this->additionalInfo();
}
return errorString.c_str();
}
std::string BaseException::type() const {
return "BaseException";
}
std::string BaseException::additionalInfo() const {
return "";
}
}
}

10
src/storm/exceptions/BaseException.h

@ -43,6 +43,16 @@ namespace storm {
*/
virtual const char* what() const NOEXCEPT override;
/*!
* Returns the type of the exception.
*/
virtual std::string type() const;
/*!
* Returns additional information about the exception.
*/
virtual std::string additionalInfo() const;
protected:
// This stream stores the message of this exception.
std::stringstream stream;

3
src/storm/exceptions/ExceptionMacros.h

@ -16,6 +16,9 @@ exception_name(exception_name const& cp) : BaseException(cp) { \
} \
~exception_name() throw() { \
} \
virtual std::string type() const override { \
return #exception_name; \
} \
template<typename T> \
exception_name& operator<<(T const& var) { \
this->stream << var; \

Loading…
Cancel
Save