Reporting errors
Once registered using flare.light()
, the @flareapp/flare-client
will automatically catch and report errors that bubble up to the window
object. This includes most errors in vanilla JavaScript code that isn't wrapped in a try…catch
block.
Errors that are caught by, for example, Axios' catch
block, will not be reported automatically. Keep on reading to find out how to send those errors to Flare too.
Reporting caught errors
You can report errors in catch
statements or error boundaries using the flare.report()
method:
import { flare } from "@flareapp/flare-client";
try {
functionThatMightThrow();
} catch (error) {
flare.report(error);
}
Sending logs to Flare
If you don't have an error object, but you just want to send a simple log message to Flare, you can use the reportMessage
method instead:
flare.reportMessage('log message');
This method has 2 optional parameters: a context object, and an exceptionClass
string:
flare.reportMessage(
'log message',
{
moreCustomContext: [1, 2, 3],
},
'CriticalLog',
);