1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Use custom exceptions everywhere

This commit is contained in:
Matias Fontanini
2017-05-13 10:59:15 -07:00
parent 1a83801722
commit 1ef5be352a
14 changed files with 37 additions and 37 deletions

View File

@@ -30,9 +30,9 @@
#ifndef TINS_ADDRESS_RANGE
#define TINS_ADDRESS_RANGE
#include <stdexcept>
#include <iterator>
#include "endianness.h"
#include "exceptions.h"
#include "detail/address_helpers.h"
namespace Tins {
@@ -198,7 +198,7 @@ public:
AddressRange(const address_type& first, const address_type& last, bool only_hosts = false)
: first_(first), last_(last), only_hosts_(only_hosts){
if (last_ < first_) {
throw std::runtime_error("Invalid address range");
throw exception_base("Invalid address range");
}
}

View File

@@ -100,6 +100,14 @@ public:
invalid_address() : exception_base("Invalid address") { }
};
/**
* \brief Exception thrown when a PDU option is set using an incorrect value
*/
class invalid_option_value : public exception_base {
public:
invalid_option_value() : exception_base("Invalid option value") { }
};
/**
* \brief Exception thrown when a field is not present in frame.
*/
@@ -204,6 +212,10 @@ public:
pcap_error(const char* message) : exception_base(message) {
}
pcap_error(const std::string& message) : exception_base(message) {
}
};
/**