Exceptions¶
Stardag exceptions for error handling.
Exception Hierarchy¶
StardagError
├── APIError
│ ├── AuthenticationError
│ ├── AuthorizationError
│ └── TokenExpiredError
└── ...
Base Exception¶
StardagError¶
Base exception for all Stardag errors.
API Exceptions¶
APIError¶
Base exception for API-related errors.
AuthenticationError¶
Raised when authentication fails:
- Invalid credentials
- Missing API key
- OAuth flow failure
Handling:
AuthorizationError¶
Raised when authenticated but not authorized:
- Insufficient permissions
- Wrong workspace/environment
- Resource access denied
TokenExpiredError¶
Raised when authentication token has expired:
Handling:
try:
sd.build(task, registry=registry)
except TokenExpiredError:
# Refresh token and retry
os.system("stardag auth refresh")
Common Error Scenarios¶
Target Root Not Configured¶
# Error: No target root configured for 'default'
# Solution:
export STARDAG_TARGET_ROOT__DEFAULT=/path/to/outputs
Task Not Complete¶
# A dependency failed to build
try:
sd.build(task)
except Exception as e:
# Check task completion status
print(task.complete()) # False
Serialization Error¶
# Output type cannot be serialized
# Ensure return type is JSON-serializable or use pickle
@sd.task
def my_task() -> dict: # JSON-serializable
return {"key": "value"}
Best Practices¶
- Catch specific exceptions - Handle
AuthenticationErrordifferently fromAPIError - Log error details - Exceptions contain useful debugging info
- Graceful degradation - Fall back to local builds if API unavailable