Error Handling Reference - React Native
Reference documentation for error handling in the Agentforce Mobile SDK for React Native.
Errors are thrown as JavaScript Error objects with a code property. Catch them in Promise rejections:
| Code | Source | Description |
|---|---|---|
INVALID_CONFIG | configure, registerViewProvider | Missing or invalid configuration fields. Missing type field, invalid type value, missing required fields, or empty componentMap. |
CONFIG_ERROR | configure | Configuration failed at the native SDK level (for example, network error, invalid credentials). |
NOT_CONFIGURED | launchConversation, startNewConversation | configure() was not called before attempting to launch. |
LAUNCH_ERROR | launchConversation (iOS) | Failed to start the conversation session. Often indicates wrong serviceApiURL (400) or server error (500). |
START_NEW_ERROR | startNewConversation (iOS) | Failed to start a new conversation. |
ERROR | launchConversation, startNewConversation (Android) | General Android error (Activity not available, initialization failure). |
INVALID_CONTEXT | setAdditionalContext | Missing variables array or a variable lacks name/type. |
NO_CONVERSATION | setAdditionalContext | No active conversation. Must call launchConversation() first. |
CONTEXT_ERROR | setAdditionalContext | The native SDK rejected the context. |
INVALID_FIELDS | registerHiddenPreChatFields (iOS) | Fields are not a valid string-to-string map. |
| Code | Source | Description |
|---|---|---|
NO_ACTIVITY | login, refreshAuthCredentials (Android) | No current Activity available. |
NOT_AVAILABLE | login, refreshAuthCredentials (Android) | Salesforce SDK not initialized. |
LOGIN_FAILED | login (Android) | No credentials obtained after login flow. |
REFRESH_FAILED | refreshAuthCredentials (Android) | No credentials available after refresh. |
ERROR | Various (Android) | General error with message. |
The bridge performs client-side validation before sending to native:
- The
contextobject must have avariablesarray. - Each variable must have a non-empty
name(string) andtype(string). - The
typemust be one of:Text,Number,Boolean,Date,DateTime,Json,List,Money,Object,Ref,Variable.
If validation fails, a synchronous Error is thrown before the native call.
| Method | iOS Error Code | Android Error Code |
|---|---|---|
launchConversation failure | LAUNCH_ERROR | ERROR |
startNewConversation failure | START_NEW_ERROR | ERROR |
| Invalid hidden prechat fields | INVALID_FIELDS | (not validated) |