diff options
| author | 2022-01-07 17:12:42 +0000 | |
|---|---|---|
| committer | 2022-01-07 17:16:50 +0000 | |
| commit | 52cc8a418307ae7a551d23e6bd2d367b544e7bf9 (patch) | |
| tree | 9fff020964190f33174e78ff6201381be577d0b3 /include/modules | |
| parent | Merge branch 'insp3' into master. (diff) | |
Refactor CoreException and ModuleException.
Diffstat (limited to 'include/modules')
| -rw-r--r-- | include/modules/dns.h | 8 | ||||
| -rw-r--r-- | include/modules/ldap.h | 10 | ||||
| -rw-r--r-- | include/modules/regex.h | 14 |
3 files changed, 20 insertions, 12 deletions
diff --git a/include/modules/dns.h b/include/modules/dns.h index 3769a4e32..4473d2be7 100644 --- a/include/modules/dns.h +++ b/include/modules/dns.h @@ -79,10 +79,14 @@ namespace DNS const int PORT = 53; - class Exception : public ModuleException + class Exception final + : public ModuleException { public: - Exception(const std::string& message) : ModuleException(message) { } + Exception(const Module* mod, const std::string& message) + : ModuleException(mod, message) + { + } }; struct Question diff --git a/include/modules/ldap.h b/include/modules/ldap.h index 760cc4ec2..5d11d89fb 100644 --- a/include/modules/ldap.h +++ b/include/modules/ldap.h @@ -20,13 +20,15 @@ typedef int LDAPQuery; +// XXX: This should be using ModuleException. class LDAPException final - : public ModuleException + : public CoreException { public: - LDAPException(const std::string& reason) : ModuleException(reason) { } - - virtual ~LDAPException() noexcept = default; + LDAPException(const std::string& msg) + : CoreException(msg) + { + } }; struct LDAPModification final diff --git a/include/modules/regex.h b/include/modules/regex.h index 72e62d807..89010a629 100644 --- a/include/modules/regex.h +++ b/include/modules/regex.h @@ -93,7 +93,7 @@ class Regex::SimpleEngine final /** @copydoc Regex::Engine::Create */ PatternPtr Create(const std::string& pattern, uint8_t options) const override { - return std::make_shared<PatternClass>(pattern, options); + return std::make_shared<PatternClass>(creator, pattern, options); } }; @@ -126,21 +126,23 @@ class Regex::Exception final { public: /** Initializes a new instance of the Regex::Exception class. + * @param mod The module which caused this exception to be thrown. * @param regex A regular expression which failed to compile. * @param error The error which occurred whilst compiling the regular expression. */ - Exception(const std::string& regex, const std::string& error) - : ModuleException("Error in regex '" + regex + "': " + error) + Exception(const Module* mod, const std::string& regex, const std::string& error) + : ModuleException(mod, "Error in regex '" + regex + "': " + error) { } /** Initializes a new instance of the Regex::Exception class. + * @param mod The module which caused this exception to be thrown. * @param regex A regular expression which failed to compile. * @param error The error which occurred whilst compiling the regular expression. * @param offset The offset at which the errror occurred. */ - Exception(const std::string& regex, const std::string& error, size_t offset) - : ModuleException("Error in regex '" + regex + "' at offset " + ConvToStr(offset) + ": " + error) + Exception(const Module* mod, const std::string& regex, const std::string& error, size_t offset) + : ModuleException(mod, "Error in regex '" + regex + "' at offset " + ConvToStr(offset) + ": " + error) { } }; @@ -190,7 +192,7 @@ inline Regex::PatternPtr Regex::Engine::CreateHuman(const std::string& pattern) size_t end = pattern.find_last_not_of("Ii"); if (!end || end == std::string::npos || pattern[end] != '/') - throw Exception(pattern, "Regex patterns must be terminated with a '/'!"); + throw Exception(creator, pattern, "Regex patterns must be terminated with a '/'!"); uint8_t options = Regex::OPT_NONE; for (const auto& flag : insp::iterator_range(pattern.begin() + end + 1, pattern.end())) |
