MCPcopy
hub / github.com/praw-dev/praw / RedditAPIException

Class RedditAPIException

praw/exceptions.py:75–108  ·  view source on GitHub ↗

Container for error messages from Reddit's API.

Source from the content-addressed store, hash-verified

73
74
75class RedditAPIException(PRAWException):
76 """Container for error messages from Reddit's API."""
77
78 @staticmethod
79 def parse_exception_list(
80 exceptions: list[RedditErrorItem | list[str]],
81 ) -> list[RedditErrorItem]:
82 """Covert an exception list into a :class:`.RedditErrorItem` list."""
83 return [
84 (
85 exception
86 if isinstance(exception, RedditErrorItem)
87 else RedditErrorItem(
88 error_type=exception[0],
89 field=exception[2] if bool(exception[2]) else "",
90 message=exception[1] if bool(exception[1]) else "",
91 )
92 )
93 for exception in exceptions
94 ]
95
96 def __init__(self, items: list[RedditErrorItem | list[str] | str]) -> None:
97 """Initialize a :class:`.RedditAPIException` instance.
98
99 :param items: Either a list of instances of :class:`.RedditErrorItem` or a list
100 containing lists of unformed errors.
101
102 """
103 if isinstance(items, list) and isinstance(items[0], str):
104 parsed_items: list[RedditErrorItem | list[str]] = [cast("list[str]", items)]
105 else:
106 parsed_items = cast("list[RedditErrorItem | list[str]]", items)
107 self.items = self.parse_exception_list(parsed_items)
108 super().__init__(*self.items)
109
110
111class RedditErrorItem:

Callers 6

parse_errorMethod · 0.90
objectifyMethod · 0.90
requestMethod · 0.90
_uploadMethod · 0.90
submitMethod · 0.90
test_itemsMethod · 0.90

Calls

no outgoing calls

Tested by 1

test_itemsMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…