Skip to main content

Error Code Handling

1. Check API Return Values

All API calls should check return values:

2. Common Error Codes

According to API documentation, main error codes:
  • 0: Success
  • -1: Engine not initialized

Handle Image Data

1. Input Image Validation

2. Image Processing Error Handling

3. Memory Management

Logging and File Operations

1. Log Configuration Error Handling

2. File Write Error Handling

Exception Handling

1. Catch and Handle Exceptions

2. Retry Mechanism

macOS-Specific Error Handling

1. Sandbox Permission Handling

2. Multi-Display Environment Error Handling

Debugging Tips

1. Error Information Collection

2. Performance Monitoring

Summary

Following these error handling best practices can help you:
  1. Improve App Stability: Through API return value checking and exception handling
  2. Improve User Experience: Through friendly error prompts and recovery mechanisms
  3. Facilitate Problem Troubleshooting: Through detailed logging and error information collection
  4. Optimize Performance: Through reasonable error recovery strategies and resource management
  5. macOS Optimization: Through sandbox permission handling and multi-display environment support
Remember to adjust error handling logic based on actual SDK error code definitions and continuously monitor and improve error handling mechanisms. The macOS platform has more memory and stronger processing capabilities compared to iOS, but also need to pay attention to special handling for sandbox permissions and multi-display environments.