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

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.