Overview
TheSalesforceAuthError enum provides detailed error information for authentication failures, including network issues, credential problems, and server errors. All errors provide user-friendly, localized descriptions suitable for display in user interfaces or logging systems.
Definition
Error Cases
invalidCredentials
- Verify all credential values are correct
- Check if credentials have expired
- Confirm user has necessary permissions
networkError
- Check network connectivity
- Implement retry logic with exponential backoff
- Verify firewall/proxy settings
- Check DNS configuration
invalidResponse
- Verify API endpoint is correct
- Check Salesforce API version compatibility
- Review response format expectations
serverError
- Check Salesforce status page for outages
- Review error message for specific guidance
- Implement retry logic for transient errors
- Contact Salesforce support if persistent
rateLimitExceeded
- Implement exponential backoff retry logic
- Queue requests to avoid rate limits
- Review API usage patterns
- Consider upgrading Salesforce plan for higher limits
Usage Example
Error Handling Strategies
Credential Errors
- Invalid Credentials: Prompt user to verify credentials
- Expired Tokens: Implement automatic token refresh
- Permission Issues: Check user permissions and roles
Network Errors
- Connectivity Issues: Implement retry logic with exponential backoff
- Timeout Errors: Increase timeout values for slow connections
- DNS Issues: Check network configuration and DNS settings
Server Errors
- Temporary Issues: Implement retry logic for transient errors
- Maintenance Windows: Check Salesforce status page
- Service Unavailable: Implement graceful degradation
Rate Limiting
- Exponential Backoff: Implement progressive retry delays
- Request Queuing: Queue requests when approaching limits
- Load Balancing: Distribute requests across time periods
Retry Logic Example
Properties
errorDescription
Conformances
Error- Standard Swift error protocolLocalizedError- Provides localized error descriptionsSendable- Safe to use across concurrency domains
