github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/python/aistore/sdk/errors.py (about)

     1  #
     2  # Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
     3  #
     4  
     5  
     6  class AISError(Exception):
     7      """
     8      Raised when an error is encountered from a query to the AIS cluster
     9      """
    10  
    11      def __init__(self, status_code: int, message: str):
    12          self.status_code = status_code
    13          self.message = message
    14          super().__init__(f"STATUS:{status_code}, MESSAGE:{message}")
    15  
    16  
    17  # pylint: disable=unused-variable
    18  class InvalidBckProvider(Exception):
    19      """
    20      Raised when the bucket provider is invalid for the requested operation
    21      """
    22  
    23      def __init__(self, provider):
    24          super().__init__(f"Invalid bucket provider {provider}")
    25  
    26  
    27  # pylint: disable=unused-variable
    28  class ErrRemoteBckNotFound(AISError):
    29      """
    30      Raised when a remote bucket its required and missing for the requested operation
    31      """
    32  
    33      def __init__(self, status_code, message):
    34          super().__init__(status_code=status_code, message=message)
    35  
    36  
    37  # pylint: disable=unused-variable
    38  class ErrBckNotFound(AISError):
    39      """
    40      Raised when a bucket is expected and not found
    41      """
    42  
    43      def __init__(self, status_code, message):
    44          super().__init__(status_code=status_code, message=message)
    45  
    46  
    47  # pylint: disable=unused-variable
    48  class ErrBckAlreadyExists(AISError):
    49      """
    50      Raised when a bucket is created but already exists in AIS
    51      """
    52  
    53      def __init__(self, status_code, message):
    54          super().__init__(status_code=status_code, message=message)
    55  
    56  
    57  # pylint: disable=unused-variable
    58  class ErrETLAlreadyExists(AISError):
    59      """
    60      Raised when an ETL is created but already exists in AIS
    61      """
    62  
    63      def __init__(self, status_code, message):
    64          super().__init__(status_code=status_code, message=message)
    65  
    66  
    67  # pylint: disable=unused-variable
    68  class Timeout(Exception):
    69      """
    70      Raised when an operation takes too long to complete
    71      """
    72  
    73      def __init__(self, action, message=""):
    74          super().__init__(f"Timed out while waiting for {action}. {message}")
    75  
    76  
    77  # pylint: disable=unused-variable
    78  class InvalidObjectRangeIndex(Exception):
    79      """
    80      Raised when incorrect range parameters are passed when creating an ObjectRange
    81      """
    82  
    83      def __init__(self, message):
    84          super().__init__(f"Invalid argument provided for object range index: {message}")
    85  
    86  
    87  class JobInfoNotFound(Exception):
    88      """
    89      Raised when information on a job's status could not be found on the AIS cluster
    90      """
    91  
    92      def __init__(self, message):
    93          super().__init__(f"Job information not found on the cluster: {message}")
    94  
    95  
    96  class UnexpectedHTTPStatusCode(Exception):
    97      """
    98      Raised when the status code from a response is not what's expected.
    99      """
   100  
   101      def __init__(self, expected_status_codes, received_status_code):
   102          expected_codes = ", ".join(str(code) for code in expected_status_codes)
   103          super().__init__(
   104              (
   105                  f"Unexpected status code received. "
   106                  f"Expected one of the following: {expected_codes}, "
   107                  f"but received: {received_status_code}"
   108              )
   109          )