LynxError API

LynxError is the standard error object returned by the Lynx runtime to indicate runtime failures, warnings, or recoverable issues in your app.

It contains both machine-readable information (error code, subcode, severity) and a human-readable message.

Overview

public int getErrorCode()

Return the error code. The error code is a 3 to 4-digit number used to denote the behavior of the error. For example, code 301 indicates a loading error for image. You can refer to documentation Error Codes to learn the specific behavior each error code represents.

getSubCode

public int getSubCode()

Return the error subcode. The error subcode is a 5 to 6-digit number derived from extending the error code by 2 digits. The error subcode is used to indicate the cause of the error. For example, subcode 30101 indicates that the loaded image is too large. You can refer to documentation Error Codes to learn the specific cause each error subcode represents.

isFatal

public boolean isFatal()

Determine if the error level is Fatal. LynxError has three levels: Fatal, Error, and Warn. Fatal indicates a critical error that might cause the Lynx page to go blank, requiring the integrator to perform fallback handling; for example, attempting to reload the Lynx page or displaying an error page. Error denotes a non-critical error that might cause some functionalities of the Lynx page to become unavailable. Warn signifies a warning error that does not affect the functionality of the Lynx page but should be addressed if possible. You can refer to documentation Error Codes to learn about the error levels associated with each subcode. If the level is Undecided, it means that the error level for that subcode is determined at runtime.

getMsg

public boolean getMsg()

Return all error information in JSON string format, including the code, subcode, error message, level, and fix suggestion.

iOS

errorCode

- (NSInteger)errorCode
PropertyTypeDescription
errorCodeintTop-level error code (e.g. 102)
subCodeintMore specific error code (e.g. 10203)
levelstringSeverity level: Fatal, Error, Warn, Undecided
msgstringHuman-readable error message
toString()stringFull string representation of the error

Use Cases

  • Display meaningful errors in debug/development mode
  • Trigger fallback UI or navigation for fatal runtime issues
  • Report issues for analytics or bug tracking

Platform Methods

Android

MethodReturn TypeDescription
getErrorCode()intReturns errorCode
getSubCode()intReturns subCode
getLevel()StringReturns severity level
getMsg()StringReturns error message
toString()StringFull stringified error

iOS

PropertyTypeDescription
errorCodeNSIntegerSame as above
subCodeNSInteger
levelNSString*
msgNSString*
descriptionNSString*Equivalent of toString()

Error Levels

LevelMeaningSuggested Action
FatalApp is likely unusableReload or fallback UI
ErrorRecoverable issueLog or retry
WarnNon-blocking warningLog and continue
UndecidedNot yet categorizedHandle gracefully, log issue

Example

JavaScript

lynx.onError((err) => {
  if (err.getLevel() === 'Fatal') {
    // Possibly reload or fallback to home
    console.error('Critical error occurred:', err.getMsg());
  }
});

Kotlin

fun onLynxError(error: LynxError) {
    if (error.level == "Fatal") {
        println("Fatal error: ${error.msg}")
    }
}

Swift

func onLynxError(_ error: LynxError) {
  if error.level == "Fatal" {
    print("Fatal error: \(error.msg)")
  }
}

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.