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 a
RedditAPIExceptioninstance.- 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: str
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: str
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: str
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)
- 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 a
DuplicateReplaceExceptioninstance.
- 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 an
InvalidFlairTemplateIDinstance.
- 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 an
InvalidImplicitAuthinstance.
- 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 an
InvalidURLinstance.- 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 a
MediaPostFailedinstance.
- 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)
- 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)
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception praw.exceptions.ReadOnlyException
Raised when a method call requires
read_onlymode to be disabled.- __init__(*args, **kwargs)
- 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 a
RedditAPIExceptioninstance.- 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: str
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: str
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: str
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, *, field: Optional[str] = None, message: Optional[str] = None)
Represents a single error returned from Reddit’s API.
- __init__(error_type: str, *, field: Optional[str] = None, message: Optional[str] = None)
Initialize a
RedditErrorIteminstance.- Parameters
error_type – The error type set on Reddit’s end.
field – The input field associated with the error, if available.
message – The associated message for the error.
- exception praw.exceptions.TooLargeMediaException(*, actual: int, maximum_size: int)
Indicate exceptions from uploading media that’s too large.
- __init__(*, actual: int, maximum_size: int)
Initialize a
TooLargeMediaExceptioninstance.- Parameters
actual – The actual size of the uploaded media.
maximum_size – The maximum 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
WebSocketExceptioninstance.- 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.
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.