use of org.acra.builder.ReportBuilder in project acra by ACRA.
the class ErrorReporter method handleException.
/**
* Send a report for a {@link Throwable} with the reporting interaction mode
* configured by the developer.
*
* @param e
* The {@link Throwable} to be reported. If null the report will
* contain a new Exception("Report requested by developer").
* @param endApplication
* Set this to true if you want the application to be ended after
* sending the report.
*/
@SuppressWarnings("unused")
public void handleException(@Nullable Throwable e, boolean endApplication) {
performDeprecatedReportPriming();
final ReportBuilder builder = new ReportBuilder();
builder.exception(e);
if (endApplication) {
builder.endApplication();
}
builder.build(reportExecutor);
}
use of org.acra.builder.ReportBuilder in project acra by ACRA.
the class ErrorReporter method handleSilentException.
/**
* Mark this report as silent as send it.
*
* @param e The {@link Throwable} to be reported. If null the report will
* contain a new Exception("Report requested by developer").
*/
@SuppressWarnings("unused")
public void handleSilentException(@Nullable Throwable e) {
performDeprecatedReportPriming();
new ReportBuilder().exception(e).sendSilently().build(reportExecutor);
}
use of org.acra.builder.ReportBuilder in project AnkiChinaAndroid by ankichinateam.
the class ACRATest method testCrashReportLimit.
@Test
public void testCrashReportLimit() throws Exception {
// To test ACRA switch on reporting, plant a production tree, and trigger a report
Timber.plant(new AnkiDroidApp.ProductionCrashReportingTree());
// set up as if the user had prefs saved to full auto
setReportConfig(FEEDBACK_REPORT_ALWAYS);
// If the user is set to always, then it's production, with interaction mode toast
// will be useful with ACRA 5.2.0
setAcraConfig("Production");
// The same class/method combo is only sent once, so we face a new method each time (should test that system later)
Exception crash = new Exception("testCrashReportSend at " + System.currentTimeMillis());
StackTraceElement[] trace = new StackTraceElement[] { new StackTraceElement("Class", "Method" + (int) System.currentTimeMillis(), "File", (int) System.currentTimeMillis()) };
crash.setStackTrace(trace);
// one send should work
CrashReportData crashData = new CrashReportDataFactory(InstrumentationRegistry.getInstrumentation().getTargetContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build()).createCrashData(new ReportBuilder().exception(crash));
assertTrue(new LimitingReportAdministrator().shouldSendReport(InstrumentationRegistry.getInstrumentation().getTargetContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
// A second send should not work
assertFalse(new LimitingReportAdministrator().shouldSendReport(InstrumentationRegistry.getInstrumentation().getTargetContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
// Now let's clear data
AnkiDroidApp.deleteACRALimiterData(InstrumentationRegistry.getInstrumentation().getTargetContext());
// A third send should work again
assertTrue(new LimitingReportAdministrator().shouldSendReport(InstrumentationRegistry.getInstrumentation().getTargetContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
}
use of org.acra.builder.ReportBuilder in project Anki-Android by ankidroid.
the class ACRATest method testCrashReportLimit.
@Test
public void testCrashReportLimit() throws Exception {
// To test ACRA switch on reporting, plant a production tree, and trigger a report
Timber.plant(new AnkiDroidApp.ProductionCrashReportingTree());
// set up as if the user had prefs saved to full auto
setReportConfig(FEEDBACK_REPORT_ALWAYS);
// If the user is set to always, then it's production, with interaction mode toast
// will be useful with ACRA 5.2.0
setAcraConfig("Production");
// The same class/method combo is only sent once, so we face a new method each time (should test that system later)
Exception crash = new Exception("testCrashReportSend at " + System.currentTimeMillis());
StackTraceElement[] trace = new StackTraceElement[] { new StackTraceElement("Class", "Method" + (int) System.currentTimeMillis(), "File", (int) System.currentTimeMillis()) };
crash.setStackTrace(trace);
// one send should work
CrashReportData crashData = new CrashReportDataFactory(getTestContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build()).createCrashData(new ReportBuilder().exception(crash));
assertTrue(new LimitingReportAdministrator().shouldSendReport(getTestContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
// A second send should not work
assertFalse(new LimitingReportAdministrator().shouldSendReport(getTestContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
// Now let's clear data
AnkiDroidApp.deleteACRALimiterData(getTestContext());
// A third send should work again
assertTrue(new LimitingReportAdministrator().shouldSendReport(getTestContext(), AnkiDroidApp.getInstance().getAcraCoreConfigBuilder().build(), crashData));
}
Aggregations