summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2013-08-27 07:29:13 +0100
committerPeter Powell <petpow@saberuk.com>2013-08-27 12:07:49 +0100
commit0e7f74a7c8e804a0223b4d88bf637649838f0412 (patch)
tree79e0ff4d3ae3cb96ff65c52490d19afaec4916cd /src/modules
parentd9d9cbe025f94523265daa72de7596467d71f5c8 (diff)
Make all regex modules throw the same exception on error.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_regex_pcre.cpp11
-rw-r--r--src/modules/extra/m_regex_posix.cpp11
-rw-r--r--src/modules/extra/m_regex_re2.cpp11
-rw-r--r--src/modules/extra/m_regex_stdlib.cpp11
-rw-r--r--src/modules/extra/m_regex_tre.cpp11
5 files changed, 5 insertions, 50 deletions
diff --git a/src/modules/extra/m_regex_pcre.cpp b/src/modules/extra/m_regex_pcre.cpp
index 04b9da0ab..01cf47178 100644
--- a/src/modules/extra/m_regex_pcre.cpp
+++ b/src/modules/extra/m_regex_pcre.cpp
@@ -29,15 +29,6 @@
# pragma comment(lib, "libpcre.lib")
#endif
-class PCREException : public ModuleException
-{
- public:
- PCREException(const std::string& rx, const std::string& error, int erroffset)
- : ModuleException("Error in regex " + rx + " at offset " + ConvToStr(erroffset) + ": " + error)
- {
- }
-};
-
class PCRERegex : public Regex
{
pcre* regex;
@@ -51,7 +42,7 @@ class PCRERegex : public Regex
if (!regex)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "pcre_compile failed: /%s/ [%d] %s", rx.c_str(), erroffset, error);
- throw PCREException(rx, error, erroffset);
+ throw RegexException(rx, error, erroffset);
}
}
diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp
index ab9fe68ff..6c52a935b 100644
--- a/src/modules/extra/m_regex_posix.cpp
+++ b/src/modules/extra/m_regex_posix.cpp
@@ -23,15 +23,6 @@
#include <sys/types.h>
#include <regex.h>
-class POSIXRegexException : public ModuleException
-{
- public:
- POSIXRegexException(const std::string& rx, const std::string& error)
- : ModuleException("Error in regex " + rx + ": " + error)
- {
- }
-};
-
class POSIXRegex : public Regex
{
regex_t regbuf;
@@ -54,7 +45,7 @@ class POSIXRegex : public Regex
error = errbuf;
delete[] errbuf;
regfree(&regbuf);
- throw POSIXRegexException(rx, error);
+ throw RegexException(rx, error);
}
}
diff --git a/src/modules/extra/m_regex_re2.cpp b/src/modules/extra/m_regex_re2.cpp
index 56d80cd68..b97b7ec0f 100644
--- a/src/modules/extra/m_regex_re2.cpp
+++ b/src/modules/extra/m_regex_re2.cpp
@@ -30,15 +30,6 @@
/* $CompileFlags: -std=c++11 */
/* $LinkerFlags: -lre2 */
-class RE2Exception : public ModuleException
-{
- public:
- RE2Exception(const std::string& rx, const std::string& error)
- : ModuleException(std::string("Error in regex ") + rx + ": " + error)
- {
- }
-};
-
class RE2Regex : public Regex
{
RE2 regexcl;
@@ -48,7 +39,7 @@ class RE2Regex : public Regex
{
if (!regexcl.ok())
{
- throw RE2Exception(rx, regexcl.error());
+ throw RegexException(rx, regexcl.error());
}
}
diff --git a/src/modules/extra/m_regex_stdlib.cpp b/src/modules/extra/m_regex_stdlib.cpp
index d69f739ec..2fa1ae090 100644
--- a/src/modules/extra/m_regex_stdlib.cpp
+++ b/src/modules/extra/m_regex_stdlib.cpp
@@ -22,15 +22,6 @@
/* $CompileFlags: -std=c++11 */
-class StdRegexException : public ModuleException
-{
- public:
- StdRegexException(const std::string& rx, const std::string& error)
- : ModuleException(std::string("Error in regex ") + rx + ": " + error)
- {
- }
-};
-
class StdRegex : public Regex
{
std::regex regexcl;
@@ -43,7 +34,7 @@ class StdRegex : public Regex
}
catch(std::regex_error rxerr)
{
- throw StdRegexException(rx, rxerr.what());
+ throw RegexException(rx, rxerr.what());
}
}
diff --git a/src/modules/extra/m_regex_tre.cpp b/src/modules/extra/m_regex_tre.cpp
index cc70f187d..c845ab374 100644
--- a/src/modules/extra/m_regex_tre.cpp
+++ b/src/modules/extra/m_regex_tre.cpp
@@ -26,15 +26,6 @@
/* $CompileFlags: pkgconfincludes("tre","tre/regex.h","") */
/* $LinkerFlags: pkgconflibs("tre","/libtre.so","-ltre") rpath("pkg-config --libs tre") */
-class TRERegexException : public ModuleException
-{
- public:
- TRERegexException(const std::string& rx, const std::string& error)
- : ModuleException("Error in regex " + rx + ": " + error)
- {
- }
-};
-
class TRERegex : public Regex
{
regex_t regbuf;
@@ -57,7 +48,7 @@ public:
error = errbuf;
delete[] errbuf;
regfree(&regbuf);
- throw TRERegexException(rx, error);
+ throw RegexException(rx, error);
}
}