Files
edbg/include/libedbg/error.hpp

27 lines
534 B
C++

#ifndef LIBEDBG_INCLUDE_ERROR_H
#define LIBEDBG_INCLUDE_ERROR_H
#include <stdexcept>
#include <cstring>
namespace edbg {
class error final : public std::runtime_error {
public:
[[noreturn]]
static void send(const std::string &msg) {
throw error(msg);
}
[[noreturn]]
static void send_errno(const std::string &pfx) {
throw error(pfx + ": " + std::strerror(errno));
}
private:
explicit error(const std::string &msg) : std::runtime_error(msg) {
}
};
}
#endif //LIBEDBG_INCLUDE_ERROR_H