import InstrumentationModule from '../../native/InstrumentationModule'; import {createCrashReport} from './createCrashReport'; enum ErrorSeverityLevel { /** * An error happened, but it did not cause a problem. */ INFO = InstrumentationModule.getConstants().ERROR_SEVERITY_LEVEL_INFO, /** * An error happened but the app recovered gracefully. */ WARNING = InstrumentationModule.getConstants().ERROR_SEVERITY_LEVEL_WARNING, /** * An error happened and caused problems to the app. */ CRITICAL = InstrumentationModule.getConstants().ERROR_SEVERITY_LEVEL_CRITICAL, } /** * Reports an error that was caught. * * This can be called in catch blocks to report interesting errors that you want to track. * * Valid severity levels: * * - {@link ErrorSeverityLevel.INFO} * - {@link ErrorSeverityLevel.WARNING} * - {@link ErrorSeverityLevel.CRITICAL} * * @param {Error} error the error to report * @param {ErrorSeverityLevel} severityLevel the error severity level */ async function reportError( error: Error, severityLevel: ErrorSeverityLevel, ): Promise { const hybridExceptionData = createCrashReport(error); const serialized = JSON.stringify(hybridExceptionData); await InstrumentationModule.reportError(serialized, severityLevel); } export {reportError, ErrorSeverityLevel};