Skip to main content

Proper error handling is crucial for creating robust and reliable connectors. Lumos provides both standard and custom error handling mechanisms to address various scenarios.

Standard Error Handling

Lumos offers a built-in exception handler that you can integrate into your connector:
This setup ensures that all HTTP error status codes are automatically handled in subsequent API calls. The HTTPHandler provides a consistent way to process and report HTTP errors across different connectors.

Custom Error Handling

For more specific error scenarios or to handle API-specific error codes, you can implement custom error handlers. Let’s examine a sample connector’s custom error handling as an example.

Parse Error Response

This function attempts to parse the JSON response from the API. If successful, it creates a abcErrorResponse object. If parsing fails, it raises the HTTP error or returns a default error response.

Define Custom Exceptions

This custom exception allows you to include abc-specific error details like the error code, affected capability, and entitlement.

Implement Custom Error Handler

This custom handler maps abc-specific error codes to appropriate Lumos error codes and messages, providing more context and better error reporting.

Register the Custom Error Handler

By adding the custom error handler to the exception_handlers list, you ensure that both standard HTTP errors and abc-specific errors are properly handled. You can now go ahead and raise your custom errors from within the connector.

Best Practises

  1. API-Specific Errors: Map API-specific error codes to meaningful messages and appropriate Lumos error codes.
  2. Contextual Information: Include relevant context (e.g., capability, entitlement) in custom exceptions to aid in error diagnosis.
  3. Consistent Error Codes: Map custom errors to standard Lumos ErrorCode values for consistency across connectors.
  4. Fallback Handling: Always include a fallback case to handle unexpected errors gracefully.