main

square/leakcanary

Last updated at: 29/12/2023 09:38

HeapAnalysisException.kt

TLDR

This file contains the definition of the HeapAnalysisException class which is a custom exception used in the Shark library.

Classes

HeapAnalysisException

The HeapAnalysisException class is a custom exception class that extends the RuntimeException class. It is used in the Shark library to represent exceptions that occur during heap analysis.

The class has the following properties and methods:

  • Properties

    • serialVersionUID - a private constant that represents the unique identifier for serialization purposes.
  • Methods

    • toString(): Overrides the toString() method of the RuntimeException class. It converts the exception stack trace to a string representation and returns it.
package shark

import java.io.PrintWriter
import java.io.StringWriter

class HeapAnalysisException(cause: Throwable) : RuntimeException(cause) {

  override fun toString(): String {
    val stringWriter = StringWriter()
    cause!!.printStackTrace(PrintWriter(stringWriter))
    return stringWriter.toString()
  }

  companion object {
    private const val serialVersionUID: Long = -2522323377375290608
  }
}