Skip to main content

Exception Hierarchy

Understanding the exception hierarchy is key to writing effective error-handling logic.
ArgusError
├── ArgusValueError
│   └── ArgusTypeError
├── ArgusConnectionError
└── ArgusAPIError
    ├── ArgusAuthenticationError
    ├── ArgusPermissionError
    ├── ArgusNotFoundError
    └── ArgusInternalServerError

Exception Reference


Client-Side Errors

These errors are raised by the client before an API request is made, indicating an issue with your code’s input or configuration.

ArgusValueError

The base class for client-side validation errors.
  • When it’s raised: When a function argument is invalid but has the correct type. For example, providing an improperly formatted API key, an empty list where one is not allowed (in strict mode), or trying to save data without an asset_id.
  • How to handle: This is a programming error. Inspect the error message to understand the validation failure and correct the arguments being passed to the SDK method.

ArgusTypeError

Inherits from ArgusValueError.
  • When it’s raised: When a function argument has the wrong Python type. For example, passing a string where a list is expected for competitors.
  • How to handle: Correct the data type of the argument you are passing to match the method’s signature.

Network Errors

ArgusConnectionError

Indicates a failure to communicate with the Argus API at the network level.
  • When it’s raised: On DNS failures, refused connections, request timeouts, or other network interruptions. This error is raised after the SDK’s internal retry mechanism has been exhausted.
  • How to handle: This is often a transient issue. You can implement your own retry logic with a longer backoff period, check your server’s network connectivity, or verify that Argus API endpoints are reachable.

API Errors (ArgusAPIError)

This is the base class for all errors returned by the Argus API (i.e., HTTP status codes 4xx and 5xx). All ArgusAPIError subclasses contain valuable context for debugging. Attributes:
  • status_code (int): The HTTP status code of the error response (e.g., 401, 404).
  • response_body (dict): The parsed JSON body of the error response from the API, which may contain a detailed error message.

ArgusAuthenticationError (Status 401)

Inherits from ArgusAPIError.
  • When it’s raised: Your API key is invalid, expired, or missing.
  • How to handle: Verify your API key in the Argus dashboard and ensure it is being correctly loaded and passed to the client.

ArgusPermissionError (Status 403)

Inherits from ArgusAPIError.
  • When it’s raised: Your API key is valid but does not have permission to perform the requested action. The most common cause is a Free-tier key (sk_) attempting to use a Platform-tier feature (like asset_id or save=True).
  • How to handle: Ensure you are using a Runtime Security Key (rsk_) for platform features.

ArgusNotFoundError (Status 404)

Inherits from ArgusAPIError.
  • When it’s raised: A specified resource could not be found. This almost always means an asset_id you provided does not exist in your Argus account.
  • How to handle: Double-check that the asset_id is correct and exists in your Argus dashboard.

ArgusInternalServerError (Status 5xx)

Inherits from ArgusAPIError.
  • When it’s raised: An unexpected error occurred on the Argus servers.
  • How to handle: This is a server-side issue. It is safe to retry the request after a short delay (e.g., using an exponential backoff strategy). If the problem persists, contact Argus support and provide the request_id from the failed call if available, as well as the error details.

Practical Error Handling Example

This example demonstrates how to catch different types of exceptions to build resilient application logic.
from repello_argus_client import ArgusClient
from repello_argus_client.errors import (
    ArgusError,
    ArgusValueError,
    ArgusAuthenticationError,
    ArgusAPIError,
    ArgusConnectionError
)

try:
    client = ArgusClient.create(
        api_key="rsk_invalid_key", # Intentionally invalid key
        asset_id="non-existent-asset"
    )
    # ... use client

except ArgusValueError as e:
    # Handle client-side configuration errors
    print(f"Configuration Error: Please check your input. Details: {e}")

except ArgusAuthenticationError as e:
    # Handle a specific API error (401)
    print(f"Authentication Failed: Please verify your API key. Status: {e.status_code}")

except ArgusAPIError as e:
    # Handle any other generic API errors (404, 500, etc.)
    print(f"An API Error occurred. Status: {e.status_code}, Body: {e.response_body}")

except ArgusConnectionError as e:
    # Handle network issues
    print(f"Network Error: Could not connect to Argus. Please check connectivity. Details: {e}")
    # Consider adding retry logic here.

except ArgusError as e:
    # A generic catch-all for any other SDK-specific errors
    print(f"An unexpected Argus SDK error occurred: {e}")