Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
exceptions.py127 linesDownload Raw Back to boto3
1# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"). You4# may not use this file except in compliance with the License. A copy of5# the License is located at6#7# https://aws.amazon.com/apache2.0/8#9# or in the "license" file accompanying this file. This file is10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF11# ANY KIND, either express or implied. See the License for the specific12# language governing permissions and limitations under the License.13 14# All exceptions in this class should subclass from Boto3Error.15import botocore.exceptions16 17 18# All exceptions should subclass from Boto3Error in this module.19class Boto3Error(Exception):20    """Base class for all Boto3 errors."""21 22 23class ResourceLoadException(Boto3Error):24    pass25 26 27# NOTE: This doesn't appear to be used anywhere.28# It's probably safe to remove this.29class NoVersionFound(Boto3Error):30    pass31 32 33# We're subclassing from botocore.exceptions.DataNotFoundError34# to keep backwards compatibility with anyone that was catching35# this low level Botocore error before this exception was36# introduced in boto3.37# Same thing for ResourceNotExistsError below.38class UnknownAPIVersionError(39    Boto3Error, botocore.exceptions.DataNotFoundError40):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 DataNotFoundError47        # to be called, it has a different __init__ signature.48        Boto3Error.__init__(self, msg)49 50 51class ResourceNotExistsError(52    Boto3Error, botocore.exceptions.DataNotFoundError53):54    """Raised when you attempt to create a resource that does not exist."""55 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 DataNotFoundError70        # to be called, it has a different __init__ signature.71        Boto3Error.__init__(self, msg)72 73 74class RetriesExceededError(Boto3Error):75    def __init__(self, last_exception, msg='Max Retries Exceeded'):76        super().__init__(msg)77        self.last_exception = last_exception78 79 80class S3TransferFailedError(Boto3Error):81    pass82 83 84class S3UploadFailedError(Boto3Error):85    pass86 87 88class DynamoDBOperationNotSupportedError(Boto3Error):89    """Raised for operations that are not supported for an operand."""90 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)98 99 100# FIXME: Backward compatibility101DynanmoDBOperationNotSupportedError = DynamoDBOperationNotSupportedError102 103 104class DynamoDBNeedsConditionError(Boto3Error):105    """Raised when input is not a condition"""106 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)114 115 116class DynamoDBNeedsKeyConditionError(Boto3Error):117    pass118 119 120class PythonDeprecationWarning(Warning):121    """122    Python version being used is scheduled to become unsupported123    in an future release. See warning for specifics.124    """125 126    pass127 
codekingpro/portable-devtools · Team Ai