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 APIException has been deprecated in favor of RedditAPIException. 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 RedditAPIException instance.

Parameters
  • items – Either a list of instances of RedditErrorItem or a list containing lists of unformed errors.

  • optional_args – Takes the second and third arguments that APIException used to take.

property error_type: str

Get error_type.

Deprecated since version 7.0: Accessing attributes through instances of RedditAPIException is 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 RedditAPIException is 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 RedditAPIException is 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 RedditErrorItem list.

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 DuplicateReplaceException instance.

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 InvalidFlairTemplateID instance.

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 InvalidImplicitAuth instance.

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 InvalidURL instance.

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 MediaPostFailed instance.

property original_exception: 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)
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_only mode 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 RedditAPIException instance.

Parameters
  • items – Either a list of instances of RedditErrorItem or a list containing lists of unformed errors.

  • optional_args – Takes the second and third arguments that APIException used to take.

property error_type: str

Get error_type.

Deprecated since version 7.0: Accessing attributes through instances of RedditAPIException is 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 RedditAPIException is 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 RedditAPIException is 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 RedditErrorItem list.

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 RedditErrorItem instance.

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.

property error_message: str

Get the completed error message string.

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 TooLargeMediaException instance.

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 WebSocketException instance.

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: Exception

Access the original_exception attribute (now deprecated).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.