Added a variant of throwOnError that takes an additional error message.
This commit is contained in:
parent
686dff506d
commit
af51973b2a
@ -11,6 +11,7 @@
|
||||
#include <span>
|
||||
#include <string>
|
||||
#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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user