The Prompt Library
CodingAPIs

Write API Error Handling Logic

Create error handling logic for failed API responses.

Select Model:

Prompt:

I need to implement robust API error handling in my application. Please create comprehensive error handling logic that gracefully manages various API failure scenarios. TECHNICAL DETAILS: - Programming language/framework: [LANGUAGE_FRAMEWORK] - API type: [API_TYPE] - Current implementation: [CURRENT_IMPLEMENTATION] - Key error scenarios: [ERROR_SCENARIOS] - Authentication method: [AUTH_METHOD] REQUIREMENTS: - Handle network failures and connectivity issues - Process different HTTP status codes appropriately - Parse and interpret API-specific error responses - Implement retry logic for transient errors - Provide meaningful user feedback - Log detailed error information for debugging - Gracefully degrade functionality when services are unavailable Please provide: 1. ERROR HANDLING APPROACH - Overall strategy and design pattern - Error categorization framework - Centralized vs. distributed handling - Response parsing methodology 2. IMPLEMENTATION CODE - Complete error handling implementation - Error detection and categorization - Retry mechanism with backoff - Error response parsing - User message generation - Logging implementation 3. USAGE EXAMPLES - Integration with API calls - Implementation in different contexts - Error propagation patterns - UI integration suggestions 4. BEST PRACTICES - Testing recommendations - Performance considerations - Maintenance approach - Security best practices - Documentation suggestions Please provide well-commented code that follows best practices for the specified language/framework, with clear explanations of the implementation details.

Related Prompts

Other prompts you might find useful

CodingAPIs

API Request Builder (GET/POST)

Generate example API requests with headers and parameters.

6 models availableView details
CodingAPIs

Explain API Response Structure

Interpret JSON or XML response and map it to data needs.

6 models availableView details
CodingAPIs

Write API Error Handling Logic

Create error handling logic for failed API responses.

6 models availableView details
CodingAPIs

Document Your API Endpoint

Write clear documentation for an API route including params and examples.

6 models availableView details