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/main/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.ClientException

Indicate exceptions that don’t involve interaction with Reddit’s API.

__init__(*args, **kwargs)
add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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

exception praw.exceptions.DuplicateReplaceException

Indicate exceptions that involve the replacement of MoreComments.

Return type:

None

__init__()

Initialize a DuplicateReplaceException instance.

Return type:

None

add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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

exception praw.exceptions.InvalidFlairTemplateID(template_id)

Indicate exceptions where an invalid flair template ID is given.

Parameters:

template_id (str)

Return type:

None

__init__(template_id)

Initialize an InvalidFlairTemplateID instance.

Parameters:

template_id (str)

Return type:

None

add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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.

Return type:

None

__init__()

Initialize an InvalidImplicitAuth instance.

Return type:

None

add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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

exception praw.exceptions.InvalidURL(url, *, message='Invalid URL: {}')

Indicate exceptions where an invalid URL is entered.

Parameters:
Return type:

None

__init__(url, *, message='Invalid URL: {}')

Initialize an InvalidURL instance.

Parameters:
  • url (str) – The invalid URL.

  • message (str) – The message to display. Must contain a format identifier ({} or {0}) (default: "Invalid URL: {}").

Return type:

None

add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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

exception praw.exceptions.MediaPostFailed

Indicate exceptions where media uploads failed..

Return type:

None

__init__()

Initialize a MediaPostFailed instance.

Return type:

None

add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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)
add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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)
add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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)
add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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

exception praw.exceptions.RedditAPIException(items)

Container for error messages from Reddit’s API.

Parameters:

items (list[RedditErrorItem | list[str] | str])

Return type:

None

__init__(items)

Initialize a RedditAPIException instance.

Parameters:

items (list[RedditErrorItem | list[str] | str]) – Either a list of instances of RedditErrorItem or a list containing lists of unformed errors.

Return type:

None

add_note(object, /)

Exception.add_note(note) – add a note to the exception

static parse_exception_list(exceptions)

Covert an exception list into a RedditErrorItem list.

Return type:

list[RedditErrorItem]

Parameters:

exceptions (list[RedditErrorItem | list[str]])

with_traceback(object, /)

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

class praw.exceptions.RedditErrorItem(error_type, *, field=None, message=None)

Represents a single error returned from Reddit’s API.

Parameters:
  • error_type (str)

  • field (str | None)

  • message (str | None)

__init__(error_type, *, field=None, message=None)

Initialize a RedditErrorItem instance.

Parameters:
  • error_type (str) – The error type set on Reddit’s end.

  • field (str | None) – The input field associated with the error, if available.

  • message (str | None) – The associated message for the error.

Return type:

None

property error_message: str

Get the completed error message string.

exception praw.exceptions.TooLargeMediaException(*, actual, maximum_size)

Indicate exceptions from uploading media that’s too large.

Parameters:
  • actual (int)

  • maximum_size (int)

Return type:

None

__init__(*, actual, maximum_size)

Initialize a TooLargeMediaException instance.

Parameters:
  • actual (int) – The actual size of the uploaded media.

  • maximum_size (int) – The maximum size of the uploaded media.

Return type:

None

add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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

exception praw.exceptions.WebSocketException(message)

Indicate exceptions caused by use of WebSockets.

Parameters:

message (str)

Return type:

None

__init__(message)

Initialize a WebSocketException instance.

Parameters:

message (str) – The exception message.

Return type:

None

add_note(object, /)

Exception.add_note(note) – add a note to the exception

with_traceback(object, /)

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