Ejemplo n.º 1
0
 /**
  * Reports success to a callback. If the callback is null, this is a no-op. Any exceptions thrown
  * by the callback are silently ignored.
  *
  * @param callback A callback; may be null.
  */
 private void handleSuccess(KeenCallback callback) {
   if (callback != null) {
     try {
       callback.onSuccess();
     } catch (Exception userException) {
       // Do nothing.
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * Handles a failure in the Keen library. If the client is running in debug mode, this will
  * immediately throw a runtime exception. Otherwise, this will log an error message and, if the
  * callback is non-null, call the {@link KeenCallback#onFailure(Exception)} method. Any exceptions
  * thrown by the callback are silently ignored.
  *
  * @param callback A callback; may be null.
  * @param e The exception which caused the failure.
  */
 private void handleFailure(KeenCallback callback, Exception e) {
   if (isDebugMode) {
     if (e instanceof RuntimeException) {
       throw (RuntimeException) e;
     } else {
       throw new RuntimeException(e);
     }
   } else {
     KeenLogging.log("Encountered error: " + e.getMessage());
     if (callback != null) {
       try {
         callback.onFailure(e);
       } catch (Exception userException) {
         // Do nothing.
       }
     }
   }
 }