java.lang.Object
com.aoapps.lang.util.ErrorPrinter
Prints errors with more detail than a standard printStackTrace() call. Is also able to
capture the error into a
String
.
TODO: Avoid repetitive sequences of stack traces to reduce total output length.
TODO: Make an extensible way to register additional error printer features, and
automatically load them via ServiceLoader
. Maybe spin this off to a
microproject if we go this far.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
Adds a new mapping between a throwable and the statement that caused it.static void
addSql
(Throwable t, PreparedStatement pstmt) Adds a new mapping between a throwable and the statement that caused it.static void
Deprecated.static void
addSQL
(Throwable t, PreparedStatement pstmt) Deprecated.Please useaddSql(java.lang.Throwable, java.sql.PreparedStatement)
instead.Gets the mappings between the given throwable and any statements that caused it.Deprecated.Please usegetSql(java.lang.Throwable)
instead.static String
Gets the entire exception report as aString
.static String
getStackTraces
(Throwable thrown, Object... extraInfo) Gets the entire exception report as aString
.static void
Deprecated.static void
printStackTraces
(Throwable t, Appendable out) static void
printStackTraces
(Throwable thrown, Appendable out, Object... extraInfo) Prints a detailed error report, including all stack traces, to the provided out.static void
printStackTraces
(Throwable t, Object... extraInfo) Deprecated.
-
Method Details
-
addSql
Adds a new mapping between a throwable and the statement that caused it.- Parameters:
sql
- The SQL statement that caused the exception.
-
addSql
Adds a new mapping between a throwable and the statement that caused it.- Parameters:
pstmt
- The SQL statement that caused the exception. This must provide the SQL statement fromPreparedStatement
.toString()
, which the PostgreSQL JDBC driver does.
-
addSQL
Deprecated.Please useaddSql(java.lang.Throwable, java.lang.String)
instead.Adds a new mapping between a throwable and the statement that caused it.- Parameters:
sql
- The SQL statement that caused the exception.
-
addSQL
Deprecated.Please useaddSql(java.lang.Throwable, java.sql.PreparedStatement)
instead.Adds a new mapping between a throwable and the statement that caused it.- Parameters:
pstmt
- The SQL statement that caused the exception. This must provide the SQL statement fromPreparedStatement
.toString()
, which the PostgreSQL JDBC driver does.
-
getSql
Gets the mappings between the given throwable and any statements that caused it.- Returns:
- The SQL statements that caused the exception or an empty list when none.
-
getSQL
Deprecated.Please usegetSql(java.lang.Throwable)
instead.Gets the mappings between the given throwable and any statements that caused it.- Returns:
- The SQL statements that caused the exception or an empty list when none.
-
printStackTraces
Deprecated. -
printStackTraces
Deprecated. -
printStackTraces
-
printStackTraces
Prints a detailed error report, including all stack traces, to the provided out. Synchronizes on out to make sure concurrently reported errors will not be mixed. If out isFlushable
, will flush the output. -
addCustomMessageHandler
-
getStackTraces
Gets the entire exception report as aString
. This is not as efficient as directly writing the report due to the extra buffering. -
getStackTraces
Gets the entire exception report as aString
. This is not as efficient as directly writing the report due to the extra buffering.
-
addSql(java.lang.Throwable, java.lang.String)
instead.