PinLog Docs
  • PinLog Logging Library
  • Implementation Guide
  • Quick Start Guide
  • Exception Handling
  • GitHub
  • Reference
    • Library Reference
      • Methods
Powered by GitBook
On this page
  • Adding custom data to the crash report.
  • Creating a report without Exception Handler
  • Disabling PinLog Exception Handler

Exception Handling

PinLog also supports Uncaught Exception Handling.

That means whenever your app crashes, PinLog calls a method that creates a so called crash report and open email app with that crash report attached to it. You can provide the message ,emailAddresses and the subject for the Email to PinLog.

Warning : PinLog force closes the application after a crash to avoid ANRs (Application Not Responding) errors

App.kt
// After initialising PinLog
PinLog.setupExceptionHandler(arrayOf("example@gmail.com"), 
"You can add additional comments in this email which may help us a lot.",
"Sorry MyApplication crashed, we will try better next time.")

Adding custom data to the crash report.

If you want to add custom data to the crash report you can add it like this from anywhere.

PinLog.CustomLogFileData().put("MyFirstCustomData", "Hello, World")
PinLog.CustomLogFileData().put("MySecodeCustomData", "Welcome to the World")

Creating a report without Exception Handler

To create a report use the below method.

This method creates a report that includes data from your CustomData, your PinLogs, applicationInfo, BuildConfigClass (if was provided while initialisation) and the application default Preferences, .

Note : The report returned is a JSONObject whose key can be retrieved from PinLog.CrashReporter.CrashDataKeys object.

try {

    //Do some stuff that might throw exceptions.
    
}catch(e:Exception){
    val myReport : JSONObject = PinLog.createReport(Thread.currentThread(),e)
    //Do whatever you want with the Report.
}

Disabling PinLog Exception Handler

If you want to disable the PinLog exception handler after you have set it, you can call this method.

PinLog.disablePinLogExceptionHandler()
PreviousQuick Start GuideNextGitHub

Last updated 2 years ago