diff --git a/source/mijin/io/stream.hpp b/source/mijin/io/stream.hpp index 1b7b0b8..4611706 100644 --- a/source/mijin/io/stream.hpp +++ b/source/mijin/io/stream.hpp @@ -11,6 +11,7 @@ #include #include #include "../container/typeless_buffer.hpp" +#include "../util/exception.hpp" namespace mijin { @@ -282,6 +283,14 @@ inline void throwOnError(mijin::StreamError error) } throw std::runtime_error(errorName(error)); } + +inline void throwOnError(mijin::StreamError error, std::string message) +{ + if (error == mijin::StreamError::SUCCESS) { + return; + } + throw std::runtime_error(message + ": " + errorName(error)); +} } // namespace mijin #endif // !defined(MIJIN_IO_STREAM_HPP_INCLUDED)