ipaddress 1.1.0
|
Declares error codes and exceptions for IP address operations. More...
#include "config.hpp"
Go to the source code of this file.
Classes | |
class | error |
The primary exception class used by the IP address library. More... | |
class | parse_error |
Exception for errors encountered during IP address parsing. More... | |
class | logic_error |
Exception for logical errors in IP address operations. More... | |
Namespaces | |
namespace | ipaddress |
Namespace dedicated to IP addresses and networks operations. | |
Functions | |
template<typename T > | |
constexpr inline void | raise_error (error_code code, uint32_t value, const T *address, size_t length) |
Raises an error with a specific error code and additional context. | |
Declares error codes and exceptions for IP address operations.
This header file is part of an IP address processing library and is responsible for defining error codes and exceptions that represent various failure states encountered during IP address parsing and processing. It includes an enumeration of error codes that cover a range of issues from syntactical errors in IP address strings to logical inconsistencies in network operations. Additionally, the file declares a base exception class tailored to encapsulate these error codes along with descriptive messages, facilitating precise error handling and reporting.
The error codes are categorized into general parsing errors, IPv4-specific errors, IPv6-specific errors, and logical errors, each with a brief description of the condition they represent. The base exception class, error
, inherits from the standard std::runtime_error
and is constructed with an error code and a message, allowing exceptions to carry both a machine-readable identifier and a human-readable explanation.
The file also includes a function template that converts an error code into an exception, streamlining the process of throwing exceptions upon encountering errors during IP address operations. This design ensures that all potential error conditions are accounted for and can be handled gracefully by client code using the library.