Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 22 additions & 33 deletions src/orb/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ class DuplicateResourceCreation(BadRequestError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))


class FeatureNotAvailable(BadRequestError):
Expand All @@ -152,13 +151,12 @@ class FeatureNotAvailable(BadRequestError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))


class RequestValidationError(BadRequestError):
Expand All @@ -174,14 +172,13 @@ class RequestValidationError(BadRequestError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.validation_errors = cast(Any, data.get("validation_errors"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))


class OrbAuthenticationError(AuthenticationError):
Expand All @@ -195,13 +192,12 @@ class OrbAuthenticationError(AuthenticationError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))


class ResourceNotFound(NotFoundError):
Expand All @@ -215,11 +211,10 @@ class ResourceNotFound(NotFoundError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.title = cast(Any, data.get("title"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))

Expand All @@ -235,13 +230,12 @@ class URLNotFound(NotFoundError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))


class ResourceConflict(ConflictError):
Expand All @@ -255,13 +249,12 @@ class ResourceConflict(ConflictError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))


class RequestTooLarge(APIStatusError):
Expand All @@ -275,13 +268,12 @@ class RequestTooLarge(APIStatusError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))


class ResourceTooLarge(APIStatusError):
Expand All @@ -295,13 +287,12 @@ class ResourceTooLarge(APIStatusError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))


class TooManyRequests(RateLimitError):
Expand All @@ -315,13 +306,12 @@ class TooManyRequests(RateLimitError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))


class OrbInternalServerError(InternalServerError):
Expand All @@ -335,10 +325,9 @@ class OrbInternalServerError(InternalServerError):

def __init__(self, message: str, *, body: object, response: httpx.Response) -> None:
data = cast(Mapping[str, object], body if is_mapping(body) else {})
title = cast(Any, data.get("title"))
super().__init__(title or message, response=response, body=body)
super().__init__(message, response=response, body=body)

self.title = title
self.status = cast(Any, data.get("status"))
self.type = cast(Any, data.get("type"))
self.detail = cast(Any, data.get("detail"))
self.title = cast(Any, data.get("title"))