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: APIException 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(error_type: str, message: str, field: Optional[str])

Indicate exception that involve responses from Reddit’s API.

__init__(error_type: str, message: str, field: Optional[str])

Initialize an instance of APIException.

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.
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__

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__()

Instantize 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.MissingRequiredAttributeException

Indicate exceptions caused by not including a required attribute.

__init__

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__

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.WebSocketException(message: str, exception: Exception)

Indicate exceptions caused by use of WebSockets.

__init__(message: str, exception: Exception)

Initialize a WebSocketException.

Parameters:
  • message – The exception message.
  • exception – The exception thrown by the websocket library.
with_traceback()

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