12
common/exceptions/index_exception.hpp
Normal file
12
common/exceptions/index_exception.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "../exception.hpp"
|
||||
|
||||
namespace nkg::exceptions {
|
||||
|
||||
class index_exception : public ::nkg::exception {
|
||||
public:
|
||||
index_exception(std::string_view file, int line, std::string_view message) noexcept :
|
||||
::nkg::exception(file, line, message) {}
|
||||
};
|
||||
|
||||
}
|
||||
12
common/exceptions/key_exception.hpp
Normal file
12
common/exceptions/key_exception.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "../exception.hpp"
|
||||
|
||||
namespace nkg::exceptions {
|
||||
|
||||
class key_exception : public ::nkg::exception {
|
||||
public:
|
||||
key_exception(std::string_view file, int line, std::string_view message) noexcept :
|
||||
::nkg::exception(file, line, message) {}
|
||||
};
|
||||
|
||||
}
|
||||
12
common/exceptions/operation_canceled_exception.hpp
Normal file
12
common/exceptions/operation_canceled_exception.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "../exception.hpp"
|
||||
|
||||
namespace nkg::exceptions {
|
||||
|
||||
class operation_canceled_exception : public ::nkg::exception {
|
||||
public:
|
||||
operation_canceled_exception(std::string_view file, int line, std::string_view message) noexcept :
|
||||
::nkg::exception(file, line, message) {}
|
||||
};
|
||||
|
||||
}
|
||||
36
common/exceptions/unix_exception.hpp
Normal file
36
common/exceptions/unix_exception.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "../exception.hpp"
|
||||
|
||||
namespace nkg::exceptions {
|
||||
|
||||
class unix_exception : public ::nkg::exception {
|
||||
public:
|
||||
using error_code_t = decltype(errno);
|
||||
|
||||
private:
|
||||
error_code_t m_error_code;
|
||||
std::string m_error_string;
|
||||
|
||||
public:
|
||||
unix_exception(std::string_view file, int line, error_code_t unix_errno, std::string_view message) noexcept :
|
||||
::nkg::exception(file, line, message), m_error_code(unix_errno), m_error_string(strerror(unix_errno)) {}
|
||||
|
||||
[[nodiscard]]
|
||||
virtual bool error_code_exists() const noexcept override {
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
virtual intptr_t error_code() const noexcept override {
|
||||
return m_error_code;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
virtual const std::string& error_string() const noexcept override {
|
||||
return m_error_string;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user