Coverage for src/nendo/schema/exception.py: 61%
57 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-14 13:48 +0100
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-14 13:48 +0100
1"""Schemas for common typed of nendo objects."""
2from __future__ import annotations
5class NendoError(Exception):
6 """Base class for nendo errors."""
8 def __init__(self, message): # noqa: D107
9 super().__init__(message)
10 self.message = message
13class NendoIdError(NendoError):
14 """Nendo error with an additional details field."""
16 def __init__(self, message, target_id): # noqa: D107
17 super().__init__(message)
18 self.target_id = target_id
21class NendoPluginError(NendoError):
22 """Generic Plugin Error.
24 Any custom plugin error should inherit from this.
25 """
28class NendoPluginConfigError(NendoPluginError):
29 """Error related to the (mis)configuration of a plugin."""
32class NendoPluginLoadingError(NendoPluginError):
33 """Error related to loading of a plugin."""
36class NendoPluginRuntimeError(NendoPluginError):
37 """Generic plugin runtime error."""
40class NendoLibraryError(NendoError):
41 """Generic library error.
43 All other library error inherit from this.
44 """
47class NendoStorageError(NendoLibraryError):
48 """Generic storage error."""
51class NendoResourceError(NendoError):
52 """Error related to a Nendo resource."""
54 def __init__(self, message, src): # noqa: D107
55 super().__init__(message)
56 self.src = src
58 def __str__(self):
59 return f"Error with resource {self.src}. Details: {self.message}"
62class NendoLibraryIdError(NendoLibraryError):
63 """A library error that refers to an item with a specified id."""
65 def __init__(self, message, target_id): # noqa: D107
66 super().__init__(message)
67 self.target_id = target_id
70class NendoUserNotFoundError(NendoLibraryIdError):
71 """Error raised if a user was accessed that does not exist."""
73 def __str__(self):
74 return f"User with ID {self.target_id} not found."
77class NendoTrackNotFoundError(NendoLibraryIdError):
78 """Error raised if a track was accessed that does not exist."""
80 def __str__(self):
81 return f"Track with ID {self.target_id} not found."
84class NendoBlobNotFoundError(NendoLibraryIdError):
85 """Error raised if a blob was accessed that does not exist."""
87 def __str__(self):
88 return f"Blob with ID {self.target_id} not found."
91class NendoCollectionNotFoundError(NendoLibraryIdError):
92 """Error raised if a collection was accessed that does not exist."""
94 def __str__(self):
95 return f"Collection with ID {self.target_id} not found."
98class NendoRelationshipNotFoundError(NendoLibraryError):
99 """Error raised if a relationship does not exist beween two IDs."""
101 def __init__(self, message, source_id, target_id): # noqa: D107
102 super().__init__(message)
103 self.source_id = source_id
104 self.target_id = target_id
106 def __str__(self):
107 return f"Relationship between {self.source_id} and {self.target_id} not found."
110class NendoPluginDataNotFoundError(NendoLibraryIdError):
111 """Error raised if a plugin data was accessed that does not exist."""
113 def __str__(self):
114 return f"Plugin data with ID {self.target_id} not found."
117class NendoFileFormatError(NendoLibraryError):
118 """Error raised if there is an error with the format of a processed file."""
121class NendoMalformedIDError(NendoLibraryIdError):
122 """Error raised if the given ID is malformed / does not represent a valid UUID."""
124 def __str__(self):
125 return f"Malformed ID {self.target_id}."
128class NendoBucketNotFoundError(NendoStorageError):
129 """A library error that refers to an item with a specified id."""
131 def __init__(self, message, bucket_name): # noqa: D107
132 super().__init__(message)
133 self.bucket_name = bucket_name
135 def __str__(self):
136 return f"Bucket with name {self.bucket_name} not found."