moto/moto/managedblockchain/exceptions.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
2.5 KiB
Python
Raw Normal View History

import json
from typing import Any, List, Tuple
from moto.core.exceptions import JsonRESTError
class ManagedBlockchainClientError(JsonRESTError):
def __init__(self, error_type: str, message: str):
super().__init__(error_type=error_type, message=message)
self.error_type = error_type
self.message = message
self.description = json.dumps({"message": self.message})
def get_headers(self, *args: Any, **kwargs: Any) -> List[Tuple[str, str]]: # pylint: disable=unused-argument
return [
("Content-Type", "application/json"),
("x-amzn-ErrorType", self.error_type),
]
def get_body(self, *args: Any, **kwargs: Any) -> str: # pylint: disable=unused-argument
return self.description
2020-05-03 18:13:40 -05:00
class BadRequestException(ManagedBlockchainClientError):
def __init__(self, pretty_called_method: str, operation_error: str):
2022-01-14 18:51:49 -01:00
super().__init__(
2020-05-03 18:13:40 -05:00
"BadRequestException",
f"An error occurred (BadRequestException) when calling the {pretty_called_method} operation: {operation_error}",
2020-05-03 18:13:40 -05:00
)
2020-05-06 21:54:59 -05:00
class InvalidRequestException(ManagedBlockchainClientError):
def __init__(self, pretty_called_method: str, operation_error: str):
2022-01-14 18:51:49 -01:00
super().__init__(
"InvalidRequestException",
f"An error occurred (InvalidRequestException) when calling the {pretty_called_method} operation: {operation_error}",
)
2020-05-06 21:54:59 -05:00
class ResourceNotFoundException(ManagedBlockchainClientError):
def __init__(self, pretty_called_method: str, operation_error: str):
2020-05-06 21:54:59 -05:00
self.code = 404
2022-01-14 18:51:49 -01:00
super().__init__(
2020-05-06 21:54:59 -05:00
"ResourceNotFoundException",
f"An error occurred (ResourceNotFoundException) when calling the {pretty_called_method} operation: {operation_error}",
2020-05-15 19:38:19 -05:00
)
class ResourceAlreadyExistsException(ManagedBlockchainClientError):
def __init__(self, pretty_called_method: str, operation_error: str):
2020-05-15 19:38:19 -05:00
self.code = 409
2022-01-14 18:51:49 -01:00
super().__init__(
2020-05-15 19:38:19 -05:00
"ResourceAlreadyExistsException",
f"An error occurred (ResourceAlreadyExistsException) when calling the {pretty_called_method} operation: {operation_error}",
2020-05-06 21:54:59 -05:00
)
class ResourceLimitExceededException(ManagedBlockchainClientError):
def __init__(self, pretty_called_method: str, operation_error: str):
self.code = 429
2022-01-14 18:51:49 -01:00
super().__init__(
"ResourceLimitExceededException",
f"An error occurred (ResourceLimitExceededException) when calling the {pretty_called_method} operation: {operation_error}",
)