landingai.exceptions
Module that defines all the exceptions used in the package, and APIs for request/response error handling.
BadRequestError
Bases: Exception
Exception raised when the request is not invalid. It could be due to that the Endpoint ID doesn't exist. Status code: 400, 413, 422 or other 4xx.
Source code in landingai/exceptions.py
ClientError
Bases: Exception
Exception raised when the server failed due to client errors. Status code: 4xx.
Source code in landingai/exceptions.py
DuplicateUploadError
Bases: Exception
Exception raised when the uploaded media is already exists in the project. Status code: 409.
Source code in landingai/exceptions.py
HttpError
Bases: Exception
Exception raised when there's something wrong with the HTTP request. This is a generic exception that is raised when no other more specific exception is appropriate. Status code: 3xx, 4xx or 5xx.
Source code in landingai/exceptions.py
HttpResponse
Abstraction for the HTTP response from the prediction endpoint. It encapulates more granular and friendly error handling logic that tailored to LandingLens.
Source code in landingai/exceptions.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
from_response(response)
classmethod
Create an instance of _HttpResponse from a requests.Response object.
Source code in landingai/exceptions.py
json()
Get json body from the response. NOTE: make sure you have checked the response and you are expecting a JSON body in response
Returns
Union[Dict[str, Any], List[Any]] the json body of the response. Currently, it could be either a dict or a list. (It may support more types in the future)
Source code in landingai/exceptions.py
raise_for_status()
Raises an exception if the HTTP status is erroneous. This method is more granular than the one provided by requests.Response. It's tailored to LandingLens model inference endpoints.
Source code in landingai/exceptions.py
InternalServerError
Bases: Exception
Exception raised when the server encounters an unexpected condition that prevents it from fulfilling the request. Status code: 5xx.
Source code in landingai/exceptions.py
InvalidApiKeyError
Bases: Exception
Exception raised when the an invalid API key is provided. This error could be raised from any SDK code, not limited to a HTTP client.
Source code in landingai/exceptions.py
PermissionDeniedError
Bases: Exception
Exception raised when the requested action is not allowed. It could be due to that the user runs out of credits or the enterprise contract expired, etc. Status code: 403.
Source code in landingai/exceptions.py
RateLimitExceededError
Bases: Exception
Exception raised when the inference request is rate limited. Status code: 429.
Source code in landingai/exceptions.py
ServiceUnavailableError
Bases: Exception
Exception raised when the requested service is unavailable temporarily. Status code: 502, 503, 504.
Source code in landingai/exceptions.py
UnauthorizedError
Bases: Exception
Exception raised when the user is not authorized to access the resource. Status code: 401.
Source code in landingai/exceptions.py
UnexpectedRedirectError
Bases: Exception
Exception raised when the client encounters an unexpected redirect. Status code: 3xx.