Import
Exception Hierarchy
Base Exception
MobileUseError
Base exception for all SDK errors.Agent Exceptions
AgentError
Base exception for agent-related errors.AgentNotInitializedError
Raised when agent methods are called before initialization. Common cause: Callingrun_task() before init()
AgentProfileNotFoundError
Raised when a specified profile is not found. Common cause: Using a profile name that hasn’t been registeredAgentTaskRequestError
Raised for task request validation errors. Common causes:- Invalid task configuration
- Conflicting parameters
AgentInvalidApiKeyError
Raised when the Minitap API key is invalid or unauthorized. Common causes:- Incorrect API key
- Expired API key
- API key not set
Device Exceptions
DeviceError
Base exception for device-related errors.DeviceNotFoundError
Raised when no device is found or device becomes disconnected. Common causes:- No device connected
- USB debugging not enabled
- Device unplugged during operation
- Check device connection:
- Enable USB debugging (Android)
- Specify device explicitly:
Server Exceptions
ServerError
Base exception for server-related errors.ServerStartupError
Raised when server startup fails. Common causes:- Port already in use
- Missing dependencies (ADB for Android, idb for iOS)
- Permission issues
- Kill zombie servers:
- Verify platform tools are installed:
Executable Exceptions
ExecutableNotFoundError
Raised when required system executables are not found in PATH. Common causes:adbnot installed (for Android)idbnot installed (for iOS)xcrunnot installed (for iOS on macOS)
- Install ADB (for Android):
- Install idb (for iOS):
- Install Xcode Command Line Tools (for iOS):
Platform Exceptions
PlatformServiceUninitializedError
Raised when attempting to use platform features without proper initialization. Common causes:MINITAP_API_KEYnot set in environment- No API key provided in PlatformTaskRequest
- Platform service not configured
PlatformServiceError
Base exception for platform service-related errors. Common causes:- Network connectivity issues
- Platform API errors
- Invalid task configuration on platform
- Check network connectivity
- Verify task exists on platform
- Check platform status at platform.mobile-use.ai
Exception Handling Best Practices
1. Always Clean Up
2. Handle Specific Exceptions
3. Check Initialization
4. Retry Logic
Complete Example
Next Steps
Troubleshooting
Common issues and solutions
Agent SDK
Agent class reference

