errorInformation
Description
Observable field for error reporting from the SDK. Monitor this field to handle SDK errors gracefully.
Type
assocArray
Usage
m.lib.observeField("errorInformation", "onErrorInformation")
function onErrorInformation(event as Object)
errorData = event.getData()
print "SDK Error: " + formatJson(errorData)
end function
Data Structure
The error data structure includes:
| Field | Type | Description |
|---|---|---|
errorCode | string | Error code identifier |
errorMessage | string | Human-readable error description |
context | object | Additional context about the error |
Example
sub setupErrorObserver()
m.lib.observeField("errorInformation", "onErrorInformation")
end sub
function onErrorInformation(event as Object)
errorData = event.getData()
if errorData <> invalid then
print "=== SDK Error ==="
print "Code: " + errorData.errorCode
print "Message: " + errorData.errorMessage
' Handle specific errors
if errorData.errorCode = "CONFIG_ERROR" then
handleConfigError(errorData)
else if errorData.errorCode = "NETWORK_ERROR" then
handleNetworkError(errorData)
else if errorData.errorCode = "DATA_ERROR" then
handleDataError(errorData)
else
handleGenericError(errorData)
end if
end if
end function
sub handleConfigError(errorData as Object)
print "Configuration error occurred"
' Show user-friendly message
showErrorDialog("Configuration error. Please check your settings.")
end sub
sub handleNetworkError(errorData as Object)
print "Network error occurred"
' Retry or show offline mode
showErrorDialog("Network error. Please check your connection.")
end sub
sub handleDataError(errorData as Object)
print "Data error occurred"
' Show error and potentially refresh
showErrorDialog("Data error. Please try again.")
end sub
sub handleGenericError(errorData as Object)
print "Generic error occurred"
showErrorDialog("An error occurred. Please try again.")
end sub
Best Practices
- Always monitor this field for error handling
- Provide user-friendly error messages
- Log errors for debugging
- Implement retry logic for recoverable errors
- Don't expose technical error details to end users