Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/boto3/exceptions.py: 68%
37 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
1# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"). You
4# may not use this file except in compliance with the License. A copy of
5# the License is located at
6#
7# https://aws.amazon.com/apache2.0/
8#
9# or in the "license" file accompanying this file. This file is
10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11# ANY KIND, either express or implied. See the License for the specific
12# language governing permissions and limitations under the License.
14# All exceptions in this class should subclass from Boto3Error.
15import botocore.exceptions
18# All exceptions should subclass from Boto3Error in this module.
19class Boto3Error(Exception):
20 """Base class for all Boto3 errors."""
23class ResourceLoadException(Boto3Error):
24 pass
27# NOTE: This doesn't appear to be used anywhere.
28# It's probably safe to remove this.
29class NoVersionFound(Boto3Error):
30 pass
33# We're subclassing from botocore.exceptions.DataNotFoundError
34# to keep backwards compatibility with anyone that was catching
35# this low level Botocore error before this exception was
36# introduced in boto3.
37# Same thing for ResourceNotExistsError below.
38class UnknownAPIVersionError(
39 Boto3Error, botocore.exceptions.DataNotFoundError
40):
41 def __init__(self, service_name, bad_api_version, available_api_versions):
42 msg = (
43 f"The '{service_name}' resource does not support an API version of: {bad_api_version}\n"
44 f"Valid API versions are: {available_api_versions}"
45 )
46 # Not using super because we don't want the DataNotFoundError
47 # to be called, it has a different __init__ signature.
48 Boto3Error.__init__(self, msg)
51class ResourceNotExistsError(
52 Boto3Error, botocore.exceptions.DataNotFoundError
53):
54 """Raised when you attempt to create a resource that does not exist."""
56 def __init__(self, service_name, available_services, has_low_level_client):
57 msg = (
58 "The '{}' resource does not exist.\n"
59 "The available resources are:\n"
60 " - {}\n".format(
61 service_name, '\n - '.join(available_services)
62 )
63 )
64 if has_low_level_client:
65 msg = (
66 f"{msg}\nConsider using a boto3.client('{service_name}') "
67 f"instead of a resource for '{service_name}'"
68 )
69 # Not using super because we don't want the DataNotFoundError
70 # to be called, it has a different __init__ signature.
71 Boto3Error.__init__(self, msg)
74class RetriesExceededError(Boto3Error):
75 def __init__(self, last_exception, msg='Max Retries Exceeded'):
76 super().__init__(msg)
77 self.last_exception = last_exception
80class S3TransferFailedError(Boto3Error):
81 pass
84class S3UploadFailedError(Boto3Error):
85 pass
88class DynamoDBOperationNotSupportedError(Boto3Error):
89 """Raised for operations that are not supported for an operand."""
91 def __init__(self, operation, value):
92 msg = (
93 f'{operation} operation cannot be applied to value {value} of type '
94 f'{type(value)} directly. Must use AttributeBase object methods '
95 f'(i.e. Attr().eq()). to generate ConditionBase instances first.'
96 )
97 Exception.__init__(self, msg)
100# FIXME: Backward compatibility
101DynanmoDBOperationNotSupportedError = DynamoDBOperationNotSupportedError
104class DynamoDBNeedsConditionError(Boto3Error):
105 """Raised when input is not a condition"""
107 def __init__(self, value):
108 msg = (
109 f'Expecting a ConditionBase object. Got {value} of type {type(value)}. '
110 f'Use AttributeBase object methods (i.e. Attr().eq()). to '
111 f'generate ConditionBase instances.'
112 )
113 Exception.__init__(self, msg)
116class DynamoDBNeedsKeyConditionError(Boto3Error):
117 pass
120class PythonDeprecationWarning(Warning):
121 """
122 Python version being used is scheduled to become unsupported
123 in an future release. See warning for specifics.
124 """
126 pass