Skip to content

Exceptions

Custom exception classes for DAPI error handling and debugging.

Base Exception

Bases: Exception

Base exception class for all dapi-related errors.

This is the parent class for all custom exceptions in the dapi library. It can be used to catch any dapi-specific error or as a base for creating new custom exceptions.

PARAMETER DESCRIPTION
message

Human-readable description of the error.

TYPE: str

Example

try: ... # Some dapi operation ... pass ... except DapiException as e: ... print(f"A dapi error occurred: {e}")

Authentication Exceptions

Bases: DapiException

Exception raised when authentication with Tapis fails.

This exception is raised when there are issues during the authentication process, such as invalid credentials, network connectivity problems, or Tapis service unavailability.

PARAMETER DESCRIPTION
message

Description of the authentication failure.

TYPE: str

Example

try: ... client = DSClient(username="invalid", password="wrong") ... except AuthenticationError as e: ... print(f"Authentication failed: {e}")

File Operation Exceptions

Bases: DapiException

Exception raised when file operations fail.

This exception covers various file-related operations including uploads, downloads, directory listings, path translations, and file existence checks.

PARAMETER DESCRIPTION
message

Description of the file operation failure.

TYPE: str

Example

try: ... client.files.upload("/nonexistent/file.txt", "tapis://system/file.txt") ... except FileOperationError as e: ... print(f"File upload failed: {e}")

Application Discovery Exceptions

Bases: DapiException

Exception raised when application discovery or retrieval fails.

This exception is raised when searching for Tapis applications fails, when a specific application cannot be found, or when retrieving application details encounters an error.

PARAMETER DESCRIPTION
message

Description of the application discovery failure.

TYPE: str

Example

try: ... app = client.apps.get_details("nonexistent-app") ... except AppDiscoveryError as e: ... print(f"App discovery failed: {e}")

System Information Exceptions

Bases: DapiException

Exception raised when retrieving system information fails.

This exception is raised when operations involving Tapis execution systems fail, such as retrieving system details, listing available queues, or checking system availability.

PARAMETER DESCRIPTION
message

Description of the system information retrieval failure.

TYPE: str

Example

try: ... queues = client.systems.list_queues("nonexistent-system") ... except SystemInfoError as e: ... print(f"System info retrieval failed: {e}")

Job Management Exceptions

Bases: DapiException

Exception raised when job submission or validation fails.

This exception is raised when there are errors during job request generation, validation, or submission to Tapis. It includes additional context about the HTTP request and response when available.

PARAMETER DESCRIPTION
message

Description of the job submission failure.

TYPE: str

request

The HTTP request object that failed.

TYPE: Request DEFAULT: None

response

The HTTP response object received.

TYPE: Response DEFAULT: None

ATTRIBUTE DESCRIPTION
request

The failed HTTP request, if available.

TYPE: Request

response

The HTTP response received, if available.

TYPE: Response

Example

try: ... job = client.jobs.submit_request(invalid_job_request) ... except JobSubmissionError as e: ... print(f"Job submission failed: {e}") ... if e.response: ... print(f"Status code: {e.response.status_code}")

Initialize JobSubmissionError with optional request/response context.

PARAMETER DESCRIPTION
message

Description of the job submission failure.

TYPE: str

request

The HTTP request that failed.

TYPE: Request DEFAULT: None

response

The HTTP response received.

TYPE: Response DEFAULT: None

Source code in dapi/exceptions.py
def __init__(self, message, request=None, response=None):
    """Initialize JobSubmissionError with optional request/response context.

    Args:
        message (str): Description of the job submission failure.
        request (requests.Request, optional): The HTTP request that failed.
        response (requests.Response, optional): The HTTP response received.
    """
    super().__init__(message)
    self.request = request
    self.response = response

request instance-attribute

request = request

response instance-attribute

response = response

Bases: DapiException

Exception raised when job monitoring or management fails.

This exception is raised when there are errors during job status monitoring, job cancellation, retrieving job details, or accessing job outputs.

PARAMETER DESCRIPTION
message

Description of the job monitoring failure.

TYPE: str

Example

try: ... status = job.monitor(timeout_minutes=60) ... except JobMonitorError as e: ... print(f"Job monitoring failed: {e}")