Fixes Android app crashing when the the tracker is not initialised.
The issue was that the code was throwing an Error class, but only catching Exception class throwables, which is not a superclass of Error. This resulted in the following kind of errors when attempting to track events before initialisation was completed:
Caused by java.lang.Error: Tracker is not initialized
at com.reactnativepiwikprosdk.PiwikProSdkModule.trackEvent(PiwikProSdkModule.java:79)
at java.lang.reflect.Method.invoke(Method.java)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:149)
Here we fix the issue by changing the type of class thrown when the tracker has not been initialised.
Yes, that is a valid concern. Looking at the code for the react native Promise.reject we see that it accepts any Throwable, of which both Error and Exception are subclassed.
Fixes Android app crashing when the the tracker is not initialised.
The issue was that the code was throwing an
Error
class, but only catchingException
class throwables, which is not a superclass ofError
. This resulted in the following kind of errors when attempting to track events before initialisation was completed:Here we fix the issue by changing the type of class thrown when the tracker has not been initialised.