Handled Exceptions

Learn how to record handled exceptions using Crash Recorder

Estimated reading time: 1 min

Last edited: 13 Dec 2019

Normally Crash Recorder mode will create a recording each time an unhandled exception occures. RevDeBug API expands this functionality and allows you to record in the same manner any handled exception.

Example - recording handled exceptions

The implementation is simple: just call RevDeBug.Storage.getStorageApi().StoreException and pass the exception object as parameter. Here is an exmaple made on our Demo application. Where a simulated exception has been added.

MainWindow.java

private void HelloRDB() {
    try {
        String who = System.getProperty("user.name");
        int currentHour = LocalDateTime.now().getHour();

        String when = (currentHour >= 12 && currentHour < 18) ? "Afternoon" :
                (currentHour >= 18 && currentHour < 22) ? "Evening" :
                        (currentHour >= 22 && currentHour < 6) ? "Night" : "Morning";

        helloPanelContent.setText("Good " + when + " " + who + " !");
        throw new Exception("TestException"); // to simulate exception
    }catch(Exception e){
        RevDeBug.Storage.getStorageApi().StoreException(e);
    }
}
  

Recording of this code execution will be stored on a RevDeBug Recording Server. You can access it with the use of RevDeBug DevOps Monitor. Monitor - code view