Skip to content

Commit b31e729

Browse files
committed
[core] Improved how errors are caught
1 parent 088a52b commit b31e729

File tree

2 files changed

+9
-32
lines changed

2 files changed

+9
-32
lines changed

chat_downloader/chat_downloader.py

+4-28
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,10 @@
3939
from .errors import (
4040
URLNotProvided,
4141
SiteNotSupported,
42-
LoginRequired,
43-
VideoUnavailable,
44-
NoChatReplay,
45-
VideoUnplayable,
46-
InvalidParameter,
4742
InvalidURL,
48-
RetriesExceeded,
49-
NoContinuation,
50-
UserNotFound,
43+
ChatDownloaderError,
5144
ChatGeneratorError,
5245
ParsingError,
53-
SiteError,
54-
NoVideos,
55-
FormatError
5646
)
5747

5848

@@ -397,29 +387,15 @@ def callback(item):
397387
log('info', 'Finished retrieving chat{}.'.format(
398388
'' if chat.is_live else ' replay'))
399389

400-
except (
401-
URLNotProvided,
402-
SiteNotSupported,
403-
LoginRequired,
404-
VideoUnavailable,
405-
NoChatReplay,
406-
VideoUnplayable,
407-
InvalidParameter,
408-
InvalidURL,
409-
RetriesExceeded,
410-
NoContinuation,
411-
UserNotFound,
412-
SiteError,
413-
NoVideos,
414-
FormatError
415-
) as e: # Expected errors
416-
log('error', e)
417390
except (
418391
ChatGeneratorError,
419392
ParsingError
420393
) as e: # Errors which may be bugs
421394
log('error', '{}. Please report this at https://github.com/xenova/chat-downloader/issues/new/choose'.format(e))
422395

396+
except ChatDownloaderError as e: # Expected errors
397+
log('error', e)
398+
423399
except ConnectionError as e:
424400
log('error', 'Unable to establish a connection. Please check your internet connection. {}'.format(e))
425401

chat_downloader/errors.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ class ChatGeneratorError(ChatDownloaderError):
8282
pass
8383

8484

85-
class SiteNotSupported(ChatDownloaderError):
86-
"""Raised when the url is valid, but the site is not supported."""
85+
class SiteError(ChatDownloaderError):
86+
"""Raised when an error occurs with a specific site."""
8787
pass
8888

8989

90-
class SiteError(ChatDownloaderError):
91-
"""Raised when an error occurs with a specific site."""
90+
class SiteNotSupported(SiteError):
91+
"""Raised when the url is valid, but the site is not supported."""
9292
pass
9393

9494

@@ -111,6 +111,7 @@ class FormatNotFound(FormatError):
111111
"""Raised when a specified format can not be found"""
112112
pass
113113

114+
114115
class FormatFileNotFound(FormatError):
115116
"""Raised when the format file can not be found"""
116117
pass

0 commit comments

Comments
 (0)