-
- All Implemented Interfaces:
-
java.lang.Thread.UncaughtExceptionHandler
public class ErrorHandler implements Thread.UncaughtExceptionHandler
Handle your errors automatically. Send them to sentry, output them to the console and/or write them to the error log!
-
-
Constructor Summary
Constructors Constructor Description ErrorHandler()
Its not recommended to use the instance.
-
Method Summary
Modifier and Type Method Description static void
enableSentry(String sentryDns)
To enable sentry reporting past the sentry dns string to this function! static void
enableSentry(String sentryDns, Double tracesSampleRate, String release)
To enable sentry reporting past the sentry dns string to this function! static void
enableCatchUncaughtException()
Enable the exception handling for uncaught exceptions. static void
enableErrorLogFile()
Enable the 'error.log' file to which the stack traces will also be written. static void
handle(Throwable e)
Handle an exception. static void
handle(Throwable e, SentryLevel level, Array<String> debugInformation)
Handle an exception and send more data to Sentry. static void
handleFatal(Throwable e)
Handle an exception and exit the program with exit a non zero exit code. static void
handleFatal(Throwable e, int exitCode)
Handle an exception and exit the program with exit a non zero exit code. void
uncaughtException(Thread t, Throwable e)
Internal function from the UncaughtExceptionHandler implementation. -
-
Method Detail
-
enableSentry
static void enableSentry(String sentryDns)
To enable sentry reporting past the sentry dns string to this function!
- Parameters:
sentryDns
- The sentry dns string for error reporting to sentry.io!
-
enableSentry
static void enableSentry(String sentryDns, Double tracesSampleRate, String release)
To enable sentry reporting past the sentry dns string to this function!
- Parameters:
sentryDns
- The sentry dns string for error reporting to sentry.io!tracesSampleRate
- https://docs.sentry.release
- https://docs.sentry.
-
enableCatchUncaughtException
static void enableCatchUncaughtException()
Enable the exception handling for uncaught exceptions. Uncaught exceptions will trigger a fatal exception!
-
enableErrorLogFile
static void enableErrorLogFile()
Enable the 'error.log' file to which the stack traces will also be written.
-
handle
static void handle(Throwable e)
Handle an exception.
- Parameters:
e
- The exception to handle.
-
handle
static void handle(Throwable e, SentryLevel level, Array<String> debugInformation)
Handle an exception and send more data to Sentry.
- Parameters:
e
- The exception to handle.level
- The error level for Sentry.debugInformation
- The debug infos.
-
handleFatal
static void handleFatal(Throwable e)
Handle an exception and exit the program with exit a non zero exit code.
- Parameters:
e
- The exception to handle.
-
handleFatal
static void handleFatal(Throwable e, int exitCode)
Handle an exception and exit the program with exit a non zero exit code.
- Parameters:
e
- The exception to handle.exitCode
- The exit code to report.
-
uncaughtException
void uncaughtException(Thread t, Throwable e)
Internal function from the UncaughtExceptionHandler implementation.
- Parameters:
t
- The current thread.e
- The uncaught exception.
-
-
-
-