Coverage for pyngrok/exception.py: 100.00%
28 statements
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-11 15:55 +0000
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-11 15:55 +0000
1__author__ = "Alex Laird"
2__copyright__ = "Copyright 2023, Alex Laird"
3__version__ = "5.2.2"
6class PyngrokError(Exception):
7 """
8 Raised when a general ``pyngrok`` error has occurred.
9 """
10 pass
13class PyngrokSecurityError(PyngrokError):
14 """
15 Raised when a ``pyngrok`` security error has occurred.
16 """
17 pass
20class PyngrokNgrokInstallError(PyngrokError):
21 """
22 Raised when an error has occurred while downloading and installing the ``ngrok`` binary.
23 """
24 pass
27class PyngrokNgrokError(PyngrokError):
28 """
29 Raised when an error occurs interacting directly with the ``ngrok`` binary.
31 :var error: A description of the error being thrown.
32 :vartype error: str
33 :var ngrok_logs: The ``ngrok`` logs, which may be useful for debugging the error.
34 :vartype ngrok_logs: list[NgrokLog]
35 :var ngrok_error: The error that caused the ``ngrok`` process to fail.
36 :vartype ngrok_error: str
37 """
39 def __init__(self, error, ngrok_logs=None, ngrok_error=None):
40 super(PyngrokNgrokError, self).__init__(error)
42 if ngrok_logs is None:
43 ngrok_logs = []
45 self.ngrok_logs = ngrok_logs
46 self.ngrok_error = ngrok_error
49class PyngrokNgrokHTTPError(PyngrokNgrokError):
50 """
51 Raised when an error occurs making a request to the ``ngrok`` web interface. The ``body``
52 contains the error response received from ``ngrok``.
54 :var error: A description of the error being thrown.
55 :vartype error: str
56 :var url: The request URL that failed.
57 :vartype url: str
58 :var status_code: The response status code from ``ngrok``.
59 :vartype status_code: int
60 :var message: The response message from ``ngrok``.
61 :vartype message: str
62 :var headers: The request headers sent to ``ngrok``.
63 :vartype headers: dict[str, str]
64 :var body: The response body from ``ngrok``.
65 :vartype body: str
66 """
68 def __init__(self, error, url, status_code, message, headers, body):
69 super(PyngrokNgrokHTTPError, self).__init__(error)
71 self.url = url
72 self.status_code = status_code
73 self.message = message
74 self.headers = headers
75 self.body = body
78class PyngrokNgrokURLError(PyngrokNgrokError):
79 """
80 Raised when an error occurs when trying to initiate an API request.
82 :var error: A description of the error being thrown.
83 :vartype error: str
84 :var reason: The reason for the URL error.
85 :vartype reason: str
86 """
88 def __init__(self, error, reason):
89 super(PyngrokNgrokURLError, self).__init__(error)
91 self.reason = reason