Exceptions in PRAW¶
In addition to exceptions under the praw.exceptions namespace shown below,
exceptions might be raised that inherit from prawcore.PrawcoreException.
Please see the following resource for information on those exceptions:
https://github.com/praw-dev/prawcore/blob/master/prawcore/exceptions.py
praw.exceptions¶
PRAW exception classes.
Includes two main exceptions: RedditAPIException for when something goes wrong
on the server side, and ClientException when something goes wrong on the
client side. Both of these classes extend PRAWException.
All other exceptions are subclassed from ClientException.
-
exception
praw.exceptions.APIException(items: Union[List[Union[praw.exceptions.RedditErrorItem, List[str], str]], str], *optional_args: str)¶ Old class preserved for alias purposes.
Deprecated since version 7.0: Class
APIExceptionhas been deprecated in favor ofRedditAPIException. This class will be removed in PRAW 8.0.-
__init__(items: Union[List[Union[praw.exceptions.RedditErrorItem, List[str], str]], str], *optional_args: str)¶ Initialize an instance of RedditAPIException.
- Parameters
items – Either a list of instances of
RedditErrorItemor a list containing lists of unformed errors.optional_args – Takes the second and third arguments that
APIExceptionused to take.
-
property
error_type¶ Get error_type.
Deprecated since version 7.0: Accessing attributes through instances of
RedditAPIExceptionis deprecated. This behavior will be removed in PRAW 8.0. Check out the PRAW 7 Migration tutorial on how to migrate code from this behavior.
-
property
field¶ Get field.
Deprecated since version 7.0: Accessing attributes through instances of
RedditAPIExceptionis deprecated. This behavior will be removed in PRAW 8.0. Check out the PRAW 7 Migration tutorial on how to migrate code from this behavior.
-
property
message¶ Get message.
Deprecated since version 7.0: Accessing attributes through instances of
RedditAPIExceptionis deprecated. This behavior will be removed in PRAW 8.0. Check out the PRAW 7 Migration tutorial on how to migrate code from this behavior.
-
static
parse_exception_list(exceptions: List[Union[praw.exceptions.RedditErrorItem, List[str]]])¶ Covert an exception list into a
RedditErrorItemlist.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.ClientException¶ Indicate exceptions that don’t involve interaction with Reddit’s API.
-
__init__(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.DuplicateReplaceException¶ Indicate exceptions that involve the replacement of MoreComments.
-
__init__()¶ Initialize the class.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.InvalidFlairTemplateID(template_id: str)¶ Indicate exceptions where an invalid flair template id is given.
-
__init__(template_id: str)¶ Initialize the class.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.InvalidImplicitAuth¶ Indicate exceptions where an implicit auth type is used incorrectly.
-
__init__()¶ Initialize the class.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.InvalidURL(url: str, message: str = 'Invalid URL: {}')¶ Indicate exceptions where an invalid URL is entered.
-
__init__(url: str, message: str = 'Invalid URL: {}')¶ Initialize the class.
- Parameters
url – The invalid URL.
message – The message to display. Must contain a format identifier (
{}or{0}). (default:"Invalid URL: {}")
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.MediaPostFailed¶ Indicate exceptions where media uploads failed..
-
__init__()¶ Initialize MediaPostFailed.
-
property
original_exception¶ Access the original_exception attribute (now deprecated).
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.MissingRequiredAttributeException¶ Indicate exceptions caused by not including a required attribute.
-
__init__(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.PRAWException¶ The base PRAW Exception that all other exception classes extend.
-
__init__(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.RedditAPIException(items: Union[List[Union[praw.exceptions.RedditErrorItem, List[str], str]], str], *optional_args: str)¶ Container for error messages from Reddit’s API.
-
__init__(items: Union[List[Union[praw.exceptions.RedditErrorItem, List[str], str]], str], *optional_args: str)¶ Initialize an instance of RedditAPIException.
- Parameters
items – Either a list of instances of
RedditErrorItemor a list containing lists of unformed errors.optional_args – Takes the second and third arguments that
APIExceptionused to take.
-
property
error_type¶ Get error_type.
Deprecated since version 7.0: Accessing attributes through instances of
RedditAPIExceptionis deprecated. This behavior will be removed in PRAW 8.0. Check out the PRAW 7 Migration tutorial on how to migrate code from this behavior.
-
property
field¶ Get field.
Deprecated since version 7.0: Accessing attributes through instances of
RedditAPIExceptionis deprecated. This behavior will be removed in PRAW 8.0. Check out the PRAW 7 Migration tutorial on how to migrate code from this behavior.
-
property
message¶ Get message.
Deprecated since version 7.0: Accessing attributes through instances of
RedditAPIExceptionis deprecated. This behavior will be removed in PRAW 8.0. Check out the PRAW 7 Migration tutorial on how to migrate code from this behavior.
-
static
parse_exception_list(exceptions: List[Union[praw.exceptions.RedditErrorItem, List[str]]])¶ Covert an exception list into a
RedditErrorItemlist.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
praw.exceptions.RedditErrorItem(error_type: str, message: str, field: Optional[str] = None)¶ Represents a single error returned from Reddit’s API.
-
__init__(error_type: str, message: str, field: Optional[str] = None)¶ Initialize an error item.
- Parameters
error_type – The error type set on Reddit’s end.
message – The associated message for the error.
field – The input field associated with the error, if available.
-
property
error_message¶ Get the completed error message string.
-
-
exception
praw.exceptions.TooLargeMediaException(maximum_size: int, actual: int)¶ Indicate exceptions from uploading media that’s too large.
-
__init__(maximum_size: int, actual: int)¶ Initialize a TooLargeMediaException.
- Parameters
maximum_size – The maximum_size size of the uploaded media.
actual – The actual size of the uploaded media.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
praw.exceptions.WebSocketException(message: str, exception: Optional[Exception])¶ Indicate exceptions caused by use of WebSockets.
-
__init__(message: str, exception: Optional[Exception])¶ Initialize a WebSocketException.
- Parameters
message – The exception message.
exception –
The exception thrown by the websocket library.
Note
This parameter is deprecated. It will be removed in PRAW 8.0.
-
property
original_exception¶ Access the original_exception attribute (now deprecated).
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-