com.kuka.common
Class ExceptionUtil

java.lang.Object
  extended by com.kuka.common.ExceptionUtil

public final class ExceptionUtil
extends Object

A class that implements common used classes for exception handling.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

Method Summary
static String formatExceptionMessage(String message, Throwable cause)
          Formats an exception message and/or an exception cause to a message.
static Throwable getRootCause(Throwable ex)
          Recursively get the root cause of an exception.
static void printStackTrace(Throwable t, PrintWriter writer)
          Prints the stack trace of the given Throwable.
static void printStackTrace(Throwable t, PrintWriter writer, boolean filter)
          Prints the stack trace of the given Throwable.
static void rethrowUnchecked(Throwable e)
          Rethrows an unchecked exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRootCause

public static Throwable getRootCause(Throwable ex)
Recursively get the root cause of an exception.

Parameters:
ex - an exception
Returns:
the root cause of the exception

rethrowUnchecked

public static void rethrowUnchecked(Throwable e)
Rethrows an unchecked exception. Must be of type RuntimeException or Error.

Parameters:
e - an unchecked exception
Throws:
IllegalArgumentException - if throwable contained a checked exception.

printStackTrace

public static void printStackTrace(Throwable t,
                                   PrintWriter writer)
Prints the stack trace of the given Throwable. The format will be comparable to that of Throwable.printStackTrace().

Parameters:
t - the throwable
writer - a PrintWriter

printStackTrace

public static void printStackTrace(Throwable t,
                                   PrintWriter writer,
                                   boolean filter)
Prints the stack trace of the given Throwable. The format will be comparable to that of Throwable.printStackTrace().

Parameters:
t - the throwable
writer - a PrintWriter
filter - if true, the stack trace will be filtered from the bottom up to suppress standard Java and RoboticsAPI stack elements until the first unknown element.

formatExceptionMessage

public static String formatExceptionMessage(String message,
                                            Throwable cause)
Formats an exception message and/or an exception cause to a message.

Parameters:
message - exception message
cause - exception cause
Returns:
the formatted exception message


Copyright © 2019. All rights reserved.