Skip to content

Commit

Permalink
add new expcetions
Browse files Browse the repository at this point in the history
  • Loading branch information
freddy36 committed Dec 27, 2023
1 parent a66f529 commit c1d9160
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions audiobookdl/assets/errors/book_has_no_audiobook.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[red]ERROR: Book has no audiobook[/red]

Only audiobooks are supported.
3 changes: 3 additions & 0 deletions audiobookdl/assets/errors/book_not_found.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[red]ERROR: Book doesn't exist[/red]

Please check the URL.
3 changes: 3 additions & 0 deletions audiobookdl/assets/errors/book_not_released.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[red]ERROR: Book is not released yet[/red]

Your don't have access to the book you are trying to download because it's not yet released.
4 changes: 4 additions & 0 deletions audiobookdl/assets/errors/download_error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[red]Download failed[/red]

Expected status code {expected_status_code}, got {status_code}
Expected content-type {expected_content_type}, got {content_type}
3 changes: 3 additions & 0 deletions audiobookdl/assets/errors/generic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[red]{heading}[/red]

{body}
18 changes: 18 additions & 0 deletions audiobookdl/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,23 @@ class UserNotAuthorized(AudiobookDLException):
class MissingBookAccess(AudiobookDLException):
error_description = "book_access"

class BookNotFound(AudiobookDLException):
error_description = "book_not_found"

class BookNotReleased(AudiobookDLException):
error_description = "book_not_released"

class BookHasNoAudiobook(AudiobookDLException):
error_description = "book_has_no_audiobook"

class ConfigNotFound(AudiobookDLException):
error_description = "config_not_found"

class GenericAudiobookDLException(AudiobookDLException):
error_description: str = "generic"

def __init__(self, heading: str, body: Optional[int] = None) -> None:
self.data = {'heading': heading, 'body': body if body else ""}

class DownloadError(AudiobookDLException):
error_description: str = "download_error"

0 comments on commit c1d9160

Please sign in to comment.