MCPcopy Index your code
hub / github.com/praw-dev/praw / RedditErrorItem

Class RedditErrorItem

praw/exceptions.py:111–164  ·  view source on GitHub ↗

Represents a single error returned from Reddit's API.

Source from the content-addressed store, hash-verified

109
110
111class RedditErrorItem:
112 """Represents a single error returned from Reddit's API."""
113
114 @property
115 def error_message(self) -> str:
116 """The completed error message string."""
117 error_str = self.error_type
118 if self.message:
119 error_str += f": {self.message!r}"
120 if self.field:
121 error_str += f" on field {self.field!r}"
122 return error_str
123
124 def __eq__(self, other: object) -> bool:
125 """Check for equality."""
126 if isinstance(other, RedditErrorItem):
127 return (self.error_type, self.message, self.field) == (
128 other.error_type,
129 other.message,
130 other.field,
131 )
132 return super().__eq__(other)
133
134 def __hash__(self) -> int:
135 """Return the hash of the current instance."""
136 return hash(self.__class__.__name__) ^ hash((self.error_type, self.message, self.field))
137
138 def __init__(
139 self,
140 error_type: str,
141 *,
142 field: str | None = None,
143 message: str | None = None,
144 ) -> None:
145 """Initialize a :class:`.RedditErrorItem` instance.
146
147 :param error_type: The error type set on Reddit's end.
148 :param field: The input field associated with the error, if available.
149 :param message: The associated message for the error.
150
151 """
152 self.error_type = error_type
153 self.message = message
154 self.field = field
155
156 def __repr__(self) -> str:
157 """Return an object initialization representation of the instance."""
158 return (
159 f"{self.__class__.__name__}(error_type={self.error_type!r}, message={self.message!r}, field={self.field!r})"
160 )
161
162 def __str__(self) -> str:
163 """Get the message returned from str(self)."""
164 return self.error_message
165
166
167class TooLargeMediaException(ClientException):

Callers 8

_uploadMethod · 0.90
test_itemsMethod · 0.90
test_equalityMethod · 0.90
test_hashMethod · 0.90
test_propertyMethod · 0.90
test_reprMethod · 0.90
test_strMethod · 0.90
parse_exception_listMethod · 0.85

Calls

no outgoing calls

Tested by 6

test_itemsMethod · 0.72
test_equalityMethod · 0.72
test_hashMethod · 0.72
test_propertyMethod · 0.72
test_reprMethod · 0.72
test_strMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…