- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.itextpdf.text.ExceptionConverter
-
- All Implemented Interfaces:
java.io.Serializable
public class ExceptionConverter extends java.lang.RuntimeExceptionThe ExceptionConverter changes a checked exception into an unchecked exception.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ExceptionConverter(java.lang.Exception ex)Construct a RuntimeException based on another Exception
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.RuntimeExceptionconvertException(java.lang.Exception ex)Convert an Exception into an unchecked exception.java.lang.ThrowablefillInStackTrace()requests to fill in the stack trace we will have to ignore.java.lang.ExceptiongetException()and allow the user of ExceptionConverter to get a handle to it.java.lang.StringgetLocalizedMessage()and make sure we also produce a localized versionjava.lang.StringgetMessage()We print the message of the checked exceptionvoidprintStackTrace()we have to override this as wellvoidprintStackTrace(java.io.PrintStream s)here we prefix, with s.print(), not s.println(), the stack trace with "ExceptionConverter:"voidprintStackTrace(java.io.PrintWriter s)Again, we prefix the stack trace with "ExceptionConverter:"java.lang.StringtoString()The toString() is changed to be prefixed with ExceptionConverter
-
-
-
Method Detail
-
convertException
public static final java.lang.RuntimeException convertException(java.lang.Exception ex)
Convert an Exception into an unchecked exception. Return the exception if it is already an unchecked exception or return an ExceptionConverter wrapper otherwise- Parameters:
ex- the exception to convert- Returns:
- an unchecked exception
- Since:
- 2.1.6
-
getException
public java.lang.Exception getException()
and allow the user of ExceptionConverter to get a handle to it.- Returns:
- the original exception
-
getMessage
public java.lang.String getMessage()
We print the message of the checked exception- Overrides:
getMessagein classjava.lang.Throwable- Returns:
- message of the original exception
-
getLocalizedMessage
public java.lang.String getLocalizedMessage()
and make sure we also produce a localized version- Overrides:
getLocalizedMessagein classjava.lang.Throwable- Returns:
- localized version of the message
-
toString
public java.lang.String toString()
The toString() is changed to be prefixed with ExceptionConverter- Overrides:
toStringin classjava.lang.Throwable- Returns:
- String version of the exception
-
printStackTrace
public void printStackTrace()
we have to override this as well- Overrides:
printStackTracein classjava.lang.Throwable
-
printStackTrace
public void printStackTrace(java.io.PrintStream s)
here we prefix, with s.print(), not s.println(), the stack trace with "ExceptionConverter:"- Overrides:
printStackTracein classjava.lang.Throwable- Parameters:
s-
-
printStackTrace
public void printStackTrace(java.io.PrintWriter s)
Again, we prefix the stack trace with "ExceptionConverter:"- Overrides:
printStackTracein classjava.lang.Throwable- Parameters:
s-
-
fillInStackTrace
public java.lang.Throwable fillInStackTrace()
requests to fill in the stack trace we will have to ignore. We can't throw an exception here, because this method is called by the constructor of Throwable- Overrides:
fillInStackTracein classjava.lang.Throwable- Returns:
- a Throwable
-
-