Overview

The nekuda SDK provides comprehensive error handling with specific error types, severity levels, and recovery suggestions. All errors follow a consistent structure to help you handle them appropriately.

Error Structure

Every error in the SDK contains the following information:
{
  code: string,           // Error code for programmatic handling
  message: string,        // Human-readable error message
  severity: string,       // 'info' | 'warning' | 'error' | 'critical'
  recoverable: boolean,   // Whether the error can be recovered from
  suggestedAction?: string, // Recommended recovery action
  fieldErrors?: Array,    // Field-specific validation errors
  context?: object       // Additional error context
}

Error Types

Validation Errors

These occur when form fields contain invalid data:
CodeDescriptionSeverity
VALIDATION_REQUIREDRequired field is emptyError
VALIDATION_INVALIDField value is invalidError
VALIDATION_EXPIREDCard has expiredError
VALIDATION_FORMATIncorrect format (e.g., card number)Error
VALIDATION_LENGTHValue too short or too longError

Network Errors

These occur when there are connectivity issues:
CodeDescriptionSeverityRecoverable
NETWORK_TIMEOUTRequest timed outWarningYes
NETWORK_OFFLINENo internet connectionErrorNo
NETWORK_CONNECTION_LOSTConnection lost during operationWarningYes

API Errors

These occur when the nekuda service returns an error:
CodeDescriptionSeverityAction
API_UNAUTHORIZEDInvalid or expired API keyCriticalCheck public key
API_FORBIDDENAccess deniedCriticalVerify permissions
API_RATE_LIMITEDToo many requestsWarningRetry after delay
API_BAD_REQUESTInvalid request dataErrorCheck input
API_SERVER_ERRORServer errorErrorContact support

Error Callbacks

The SDK provides two main error callbacks on the NekudaWalletProvider:

onValidationError

Called when field validation fails. Receives an array of field-specific errors.
<NekudaWalletProvider
  publicKey="pk_test_..."
  userId="user_123"
  onValidationError={(fieldErrors) => {
    // fieldErrors: Array of { fieldName, message, fieldType }
    const errorMessages = fieldErrors.map(e => e.message).join(', ');
    setFormError(errorMessages);
  }}
>

onError

Called for all other errors (network, API, configuration).
<NekudaWalletProvider
  publicKey="pk_test_..."
  userId="user_123"
  onError={(error) => {
    // error: { code, message, severity, recoverable, suggestedAction }
    if (error.recoverable) {
      // Can retry the operation
      handleRetry();
    } else {
      // Show error to user
      showErrorNotification(error.message);
    }
  }}
>

Error Recovery

The SDK provides suggested actions for different error types:
Suggested ActionWhen UsedExample Implementation
retryNetwork timeouts, rate limitsRetry after delay
check_inputValidation errorsHighlight invalid fields
reauthenticateAuth errorsRefresh API key
contact_supportServer errorsShow support contact
refreshIframe issuesReload the page

Common Error Scenarios

Invalid Card Number

// Error received in onValidationError
{
  fieldName: "cardNumber",
  fieldType: "cardNumber",
  message: "Please enter a valid card number"
}

Expired Card

// Error received in onValidationError
{
  fieldName: "cardExpiry",
  fieldType: "cardExpiry", 
  message: "Card has expired"
}

Rate Limited

// Error received in onError
{
  code: "API_RATE_LIMITED",
  message: "Too many requests. Please wait before trying again.",
  severity: "warning",
  recoverable: true,
  suggestedAction: "retry"
}

Network Timeout

// Error received in onError
{
  code: "NETWORK_TIMEOUT",
  message: "Request timed out. Please try again.",
  severity: "warning",
  recoverable: true,
  suggestedAction: "retry"
}

Best Practices

1

Always Set Both Error Handlers

Configure both onValidationError and onError on your provider to catch all error types.
2

Check Error Severity

Handle errors based on severity - critical errors may require page reload, while warnings can be retried.
3

Use Suggested Actions

Follow the suggestedAction field when present for appropriate error recovery.
4

Provide User Feedback

Always inform users when errors occur with clear, actionable messages.
5

Log Errors

Log errors to your monitoring service for debugging and improving user experience.

Troubleshooting

Payment Form Not Loading

If the payment form doesn’t appear:
  • Check browser console for error messages
  • Verify your public key is correct
  • Ensure nekuda domains aren’t blocked by CSP or firewall

Validation Errors Not Showing

If validation errors aren’t displayed:
  • Ensure you’ve implemented the onValidationError callback
  • Check that field error messages are being rendered in your UI

Network Errors

For persistent network errors:
  • Check internet connectivity
  • Verify nekuda services are accessible
  • Check for proxy or VPN interference
For additional support, contact our support team with the error code and message.