Errors and logging
The error handler that reports uncaught errors to Lynx, and a logger that sends device logs to a file on your computer. import { LynxErrorHandler, LynxLogger } from '@blotch/angular-lynx';
Usage
While ng serve runs, the message goes to .dev-logs in the folder you ran it from. Follow it with tail -f .dev-logs. See Stream logs to your computer.
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 writes them to .dev-logs. 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.
- Sent through the background thread. Your app runs on the main thread, which has no network access of its own. So each message goes to the background thread, which posts it to the dev server the app loaded from.
- Objects and errors. Objects and arrays print as indented JSON, and an
Errorprints with its stack. Other values, and an object JSON can't hold (such as a circular one), print asString()makes them.
LynxLogger.log(), info(), warn(), error() and debug()
Send one log entry at that level. The arguments print separated by spaces.
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.
