3

Is it possible to send custom data with acra without actually having a Throwable?

I´ve seen that it is possible to append custom crashdata by using

ACRA.getErrorReporter().putCustomData()

But the data will only be send if there will follow an exception.

The intention of doing it is an app I´m working on, which uses webview and I want to send Javascript errors as well as native ones.

Marian Klühspies
  • 15,824
  • 16
  • 93
  • 136
  • I'm sure it is possible at least if you look into the implementation details, but what about simply manufacturing an Exception to throw? Exception handling is less efficient than other program flows, but that is probably not significant if you are going to be pushing the result to an external server anyway. – Chris Stratton Feb 18 '14 at 16:52

1 Answers1

9

I just found the way, you just need to give null as parameter instead of an Exception, for example:

ACRA.getErrorReporter().putCustomData("myKey", "myValue");
ACRA.getErrorReporter().handleException(null);

These 2 lines will report this error:

java.lang.Exception: Report requested by developer

With the following as custom data in the report:

{myKey:myValue} 
Yoann Hercouet
  • 17,894
  • 5
  • 58
  • 85