Exceptions Module

Exceptions for arraybridge.

exception MemoryConversionError(source_type, target_type, method, reason)[source]

Bases: Exception

Exception raised when memory conversion fails.

source_type

The source memory type

target_type

The target memory type

method

The conversion method that was attempted

reason

The reason for the failure

__init__(source_type, target_type, method, reason)[source]

Exception Classes

MemoryConversionError

class MemoryConversionError(source_type, target_type, method, reason)[source]

Exception raised when memory conversion fails.

source_type

The source memory type

target_type

The target memory type

method

The conversion method that was attempted

reason

The reason for the failure

__init__(source_type, target_type, method, reason)[source]

Examples

Catching Conversion Errors

from arraybridge import convert_memory
from arraybridge.exceptions import MemoryConversionError
import numpy as np

try:
    data = np.array([1, 2, 3])
    result = convert_memory(data, 'numpy', 'invalid_type', gpu_id=0)
except MemoryConversionError as e:
    print(f"Conversion failed: {e}")
    print(f"Source: {e.source_type}")
    print(f"Target: {e.target_type}")
    print(f"Method: {e.method}")
    print(f"Reason: {e.reason}")