Skip to main content

Error Handling Basics

1. Use try-catch

All asynchronous operations should use try-catch for error handling:

2. Check Engine Initialization

3. Check API Call Results

Common Error Codes

FacebetterError Error Codes

FacebetterError error codes can be numbers or strings: Numeric error codes (from WASM layer):
  • 0: Success
  • -1: General error (engine not initialized, invalid parameters, etc.)
  • Other negative numbers: Error codes returned by specific operations
String error codes (from JS layer):
  • ‘TIMEOUT’: Operation timeout (WASM loading timeout, authentication timeout, etc.)
  • ‘NETWORK_ERROR’: Network error (online authentication failure, etc.)
  • ‘WASM_LOAD_ERROR’: WASM module loading failed
  • ‘LICENSE_ERROR’: License verification failed
  • ‘AUTH_TIMEOUT’: Online authentication timeout
  • ‘AUTH_EMPTY_RESPONSE’: Online authentication returned empty response
  • ‘ENGINE_CREATE_FAILED’: Engine creation failed (may be due to license or resource path issues)
  • ‘UNKNOWN_ERROR’: Unknown error

Image Data Error Handling

1. Input Image Validation

2. Canvas Error Handling

Network Error Handling

1. Online Verification Error

2. WASM Loading Error

Error Handling Best Practices

1. Unified Error Handler

2. User-Friendly Error Messages

3. Error Logging

Preventive Error Handling

1. Parameter Validation

2. State Checking