The lynx.reportError
method is used to manually report an error from JavaScript.
lynx.reportError
the first arg can receive a string or a JavaScript Error object. The second arg can receive an object with a level
property,where level
indicates the level of the error, with the fatal
level interrupting the execution environment to prevent further chaining of errors.
If a string is passed, reportError
will construct an error object with JSON.stringify(error)
as the message.
Which means
is equivalent with
None (undefined
).
A common use case is when an exception occurs in an asynchronous callback:
But this will result in an error stack like this:
This first frame points to the lynx.reportError
method and the second frame points to the callback passed to fetch
. No more information could be found from the error stack. We could never know who calls the getData
method from the reported error stack.
This is because Lynx uses polyfilled Promise
and does not track asynchronous call stacks.
To get a readable error stack, we could construct an error object before entering asynchronous process.
LCD tables only load in the browser