cd naka3/playbooks/three-miners && ./three-miners.sh snapshot create
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 tests/example-transfer.pyException
└── StacksException (base)
├── StacksAPIException
│ └── StacksHTTPException
├── StacksCLIException
├── StacksValidationException
└── StacksNetworkException
└── StacksTimeoutException
- StacksException (Base exception) - Base exception for all Stacks-related errors - Parent class for all other custom exceptions
- StacksAPIException - Inherits from: StacksException - Purpose: General API-related exceptions - Used for: Unexpected API parsing errors
- StacksHTTPException - Inherits from: StacksAPIException - Purpose: HTTP-specific API exceptions - Extra attributes: status_code, error_details - Used for: HTTP errors, API response failures (4xx, 5xx status codes)
- StacksCLIException - Inherits from: StacksException - Purpose: CLI-related exceptions - Extra attributes: return_code, stderr - Used for: Blockstack CLI command failures
- StacksValidationException - Inherits from: StacksException - Purpose: Data validation exceptions - Used for: Invalid data/parameter validation failures, Pydantic errors
- StacksNetworkException - Inherits from: StacksException - Purpose: Network/connection related exceptions - Used for: Network connectivity issues, connection errors
- StacksTimeoutException - Inherits from: StacksNetworkException - Purpose: Timeout-specific exceptions - Used for: Operation timeouts (confirmation waits, miner startup, etc.)
Pydantic is a Python library for data validation and parsing using type hints. We're using it for:
- Type-safe data models - All classes like Account, TransferInfo, DeploymentInfo inherit from BaseModel
- Automatic validation - Ensures data types are correct when creating objects
- IDE autocompletion - Provides full IntelliSense support
- JSON serialization/deserialization - Easy conversion to/from JSON
Black is an opinionated formatter that automatically fixes code style issues like spacing, line breaks, and quote consistency. Common usage:
- black . - Format all Python files in current directory
- black --line-length 100 . - Use 100 char line limit instead of default 88
To see debug logs, you need to set the LOG_LEVEL environment variable to debug:
LOG_LEVEL=debug python3 tests/example-transfer.py
This will show all log levels including debug messages. The available log levels are:
- LOG_LEVEL=debug - Shows everything (debug, info, warning, error)
- LOG_LEVEL=info - Shows info, warning, error (default)
- LOG_LEVEL=warning - Shows only warning and error
- LOG_LEVEL=error - Shows only error messages
You can also set it for the current session: export LOG_LEVEL=debug python3 tests/example-transfer.py
The debug messages will appear with the format: [21:19:02][DEBG] Debug information here
The RecipeFailedException is now available throughout your codebase for any scenario where you need explicit control over test failure and cleanup. It includes:
- step: Which step failed (for debugging)
- details: Specific error details
- Inherits from StacksException: Maintains your exception hierarchy
Use it wherever you need to explicitly escape from a try block and trigger cleanup in test scenarios. It's perfect for recipe/test failures that need special handling.