From 1d0c368746e0ae28ea042edaf4c75ee3a2b738c2 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Thu, 26 Nov 2020 15:12:11 +0100 Subject: [enh] record details exception per engine add an new API /stats/errors --- searx/exceptions.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'searx/exceptions.py') diff --git a/searx/exceptions.py b/searx/exceptions.py index 2d1b1167e..82c1d76dc 100644 --- a/searx/exceptions.py +++ b/searx/exceptions.py @@ -34,8 +34,45 @@ class SearxParameterException(SearxException): class SearxSettingsException(SearxException): + """Error while loading the settings""" def __init__(self, message, filename): super().__init__(message) self.message = message self.filename = filename + + +class SearxEngineException(SearxException): + """Error inside an engine""" + + +class SearxXPathSyntaxException(SearxEngineException): + """Syntax error in a XPATH""" + + def __init__(self, xpath_spec, message): + super().__init__(str(xpath_spec) + " " + message) + self.message = message + # str(xpath_spec) to deal with str and XPath instance + self.xpath_str = str(xpath_spec) + + +class SearxEngineResponseException(SearxEngineException): + """Impossible to parse the result of an engine""" + + +class SearxEngineAPIException(SearxEngineResponseException): + """The website has returned an application error""" + + +class SearxEngineCaptchaException(SearxEngineResponseException): + """The website has returned a CAPTCHA""" + + +class SearxEngineXPathException(SearxEngineResponseException): + """Error while getting the result of an XPath expression""" + + def __init__(self, xpath_spec, message): + super().__init__(str(xpath_spec) + " " + message) + self.message = message + # str(xpath_spec) to deal with str and XPath instance + self.xpath_str = str(xpath_spec) -- cgit v1.2.3