Errors and logging
The error handler that reports uncaught errors to Lynx, and a logger that prints device logs in your terminal. import { LynxErrorHandler, LynxLogger } from '@blotch/angular-lynx';
Usage
The message appears in the terminal that runs ng serve.
API
LynxErrorHandler
Angular's ErrorHandler for Lynx. provideRenderer() provides it, so you don't add it yourself.
To add your own handling, extend it and provide your class after provideRenderer():
LynxErrorHandler.handleError()
Reports an uncaught error to Lynx as a fatal error, which can show Lynx's red error overlay on a device. A value that isn't an Error is wrapped in one. Unlike Angular's default handler, it doesn't call console.error.
LynxErrorHandler.onViewError()
Angular calls this for a rendering error that an @boundary block caught. It reports the error to Lynx as a warning, not a crash, because the boundary already shows its @error content.
LynxLogger
Sends log messages from the device to the dev server, which prints them in your terminal. There's no browser console on a phone, so this is how you see logs from Lynx Explorer.
- Development builds only. In a production build, every method does nothing.
- Works from both threads. Event handlers on the main thread can log too.
- Strings only. Each argument goes through
String(), so an object prints as[object Object]. PassJSON.stringify(value)instead. - Twice from shared code. Code that runs on both threads, such as a constructor, logs once from each.
LynxLogger.log(), info(), warn(), error() and debug()
Send one log entry at that level, with each argument converted to a string.
Types
None of its own. ErrorHandler and ErrorDetails come from @angular/core.
Related
- Handling errors:
@boundaryand error states. - Debugging: Lynx DevTool, logs and on-screen errors.
- Bootstrap: what
provideRenderer()provides.
