forked from adafruit/Adafruit_CircuitPython_HTTPServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
64 lines (47 loc) · 1.56 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# SPDX-FileCopyrightText: Copyright (c) 2023 Michał Pokusa
#
# SPDX-License-Identifier: MIT
"""
`adafruit_httpserver.exceptions`
====================================================
* Author(s): Michał Pokusa
"""
class ServerStoppedError(Exception):
"""
Raised when ``.poll`` is called on a stopped ``Server``.
"""
class AuthenticationError(Exception):
"""
Raised by ``require_authentication`` when the ``Request`` is not authorized.
"""
class InvalidPathError(Exception):
"""
Parent class for all path related errors.
"""
class ParentDirectoryReferenceError(InvalidPathError):
"""
Path contains ``..``, a reference to the parent directory.
"""
def __init__(self, path: str) -> None:
"""Creates a new ``ParentDirectoryReferenceError`` for the ``path``."""
super().__init__(f"Parent directory reference in path: {path}")
class BackslashInPathError(InvalidPathError):
"""
Backslash ``\\`` in path.
"""
def __init__(self, path: str) -> None:
"""Creates a new ``BackslashInPathError`` for the ``path``."""
super().__init__(f"Backslash in path: {path}")
class ServingFilesDisabledError(Exception):
"""
Raised when ``root_path`` is not set and there is no handler for ``request``.
"""
class FileNotExistsError(Exception):
"""
Raised when a file does not exist.
"""
def __init__(self, path: str) -> None:
"""
Creates a new ``FileNotExistsError`` for the file at ``path``.
"""
super().__init__(f"File does not exist: {path}")