Skip to content

Commit a1dfd49

Browse files
committed
Use __doc__ as default message in Tgbox errors
1 parent d1ad713 commit a1dfd49

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

tgbox/api/remote.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ async def get_remotebox(
204204
) from None
205205
except ValueError:
206206
# ValueError: Could not find the input entity for PeerChannel
207-
raise RemoteBoxInaccessible(RemoteBoxInaccessible.__doc__) from None
207+
raise RemoteBoxInaccessible() from None
208208

209209
if not dlb:
210210
logger.debug('DLB is NOT specified, return EncryptedRemoteBox')
@@ -2945,9 +2945,9 @@ async def update_metadata(self, changes: Dict[str, Union[bytes, None]]):
29452945
try:
29462946
await self._rb._tc.edit_message(self._message, updates_encoded)
29472947
except MediaCaptionTooLongError:
2948-
raise NoPlaceLeftForMetadata(NoPlaceLeftForMetadata.__doc__) from None
2948+
raise NoPlaceLeftForMetadata() from None
29492949
except ChatAdminRequiredError:
2950-
raise NotEnoughRights(NotEnoughRights.__doc__) from None
2950+
raise NotEnoughRights() from None
29512951
except MessageIdInvalidError as e:
29522952
raise InvalidFile('Can\'t edit caption of this Document') from e
29532953
except MessageNotModifiedError as e:

tgbox/errors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
class TgboxException(Exception):
44
"""Base TGBOX Exception"""
55

6+
def __init__(self, message=None):
7+
super().__init__(message or self.__doc__)
8+
69
# Base Exceptions
710

811
class NotInitializedError(TgboxException):

tgbox/keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def decode(cls, encoded_key: str) -> Union[
233233
ekey_type = ekey_types[encoded_key[0]]
234234
return ekey_type(urlsafe_b64decode(encoded_key[1:]))
235235
except Exception as e:
236-
raise IncorrectKey(IncorrectKey.__doc__) from e
236+
raise IncorrectKey() from e
237237

238238
def encode(self) -> str:
239239
"""Encode raw key with ``urlsafe_b64encode`` and add prefix."""

0 commit comments

Comments
 (0)