Corsair
PluginsHubSpot

HubSpot Error Handlers

Built-in and custom error handling for HubSpot

The HubSpot plugin includes comprehensive error handling with built-in handlers for common error scenarios. You can also add custom error handlers to handle specific cases in your application.

New to Corsair? Learn about core concepts like error handling and retry strategies before customizing error handlers.

Full Implementation: For the complete, up-to-date error handler implementations, see the HubSpot plugin source code on GitHub.

Built-in Error Handlers

The HubSpot plugin automatically handles common error scenarios with sensible retry strategies.

Permission Errors

Triggers: HTTP 403 status, or error messages containing "forbidden", "permission denied", or "access denied"

Behavior:

  • Maximum retries: 0 (no retries)
  • Logs warning to console
  • Fails immediately for manual intervention

Special Handling: For ticket-related operations, permission errors are automatically detected and not retried.


Validation Errors

Triggers: HTTP 400 status for engagement creation

Behavior:

  • Maximum retries: 0 (no retries)
  • Logs error to console
  • Fails immediately

Rate Limit Errors

Triggers: HTTP 429 status

Behavior:

  • Maximum retries: 5
  • Uses exponential backoff between retries

Authentication Errors

Triggers: HTTP 401 status, or error messages containing "Invalid token" or "Unauthorized"

Behavior:

  • Maximum retries: 0 (no retries)
  • Logs error to console
  • Fails immediately for manual intervention

Network Errors

Triggers: Network-related error messages

Behavior:

  • Maximum retries: 3
  • Uses exponential backoff
  • Logs warning to console

Default Error Handler

Triggers: Any error not matched by other handlers

Behavior:

  • Maximum retries: 0 (no retries)
  • Logs error to console with context
  • Fails immediately

Custom Error Handlers

You can add custom error handlers to handle specific scenarios:

corsair.ts
hubspot({
    errorHandlers: {
        CUSTOM_ERROR: {
            match: (error, context) => {
                return error.message.includes("custom_error_code");
            },
            handler: async (error, context) => {
                return {
                    maxRetries: 2,
                };
            },
        },
    },
})

For comprehensive error handling strategies, patterns, and best practices, see the Error Handling concepts page.