|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--java.lang.RuntimeException
|
+--multex.Failure
Indirectly caused exception with parameters, causal chain and message text. This class serves for the framework user as a base class for defining Failure-exceptions, which have the following benefits:
Exc.
For convenience ist is additionally possible to give unnamed parameters
to this exception. But they cannot be inserted into a message text pattern.
They will be only appended to the text in a standard way for diagnostics
output.
Naming convention: All user-defined exception classes derived from Failure should have a name ending in Failure. The pattern is:
class OperationnameFailure extends Failure { ... }
So you can specify Failure, but you need not to do this. This is in my opinion not the cleanest way, but even without Failure you could not base on the assumption, that a method without a throws-clause does not throw any exception. Any method could throw any java.lang.RuntimeException, e.g. the IndexOutOfBoundsException.
If you want to strictly check Failure, then you can change the superclass of Failure to the checked java.lang.Exception instead of the unchecked java.lang.RuntimeException. Up to now I am not sure, what is the best way. Please report your experiences.
| Constructor Summary | |
Failure(java.lang.String i_defaultMessageTextPattern,
java.lang.Exception i_cause)
Constructs a parameterized Failure-exception, giving only the causing Exception object. |
|
Failure(java.lang.String i_defaultMessageTextPattern,
java.lang.Exception i_cause,
java.lang.Object[] i_unnamedParameters)
Constructs a Failure-exception, giving the causing Exception object for providing the diagnostics causer chain and unnamed message parameters as an Object[]. |
|
| Method Summary | |
java.lang.Exception |
cause()
Result: The Exception, which caused the program to throw this Failure-exception. |
static java.lang.Exception |
cause(java.lang.Throwable i_throwable)
Result: the causing Exception of i_throwable, if there is one, otherwise null. |
java.lang.String |
getDefaultMessageTextPattern()
Returns the default message text pattern for i_throwable or null. |
java.lang.String |
getMessage()
Returns the exception parameters of this object or null. |
static void |
printCompactStackTrace(java.lang.StringBuffer io_buffer,
java.lang.Throwable i_reportee,
java.lang.Exception i_here)
Prints the stack trace of i_throwable and all its chained cause exceptions to io_printer. |
void |
printStackTrace()
Prints the chained, redundant stack traces of this Failure
object to the standard error stream System.err |
void |
printStackTrace(java.io.PrintStream io_printer)
Prints the chained, redundant stack traces of this Failure
object to io_printer. |
void |
printStackTrace(java.io.PrintWriter io_printer)
Prints the chained, redundant stack traces of this Failure
object to io_printer.
|
| Methods inherited from class java.lang.Throwable |
fillInStackTrace,
getLocalizedMessage,
toString |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Constructor Detail |
public Failure(java.lang.String i_defaultMessageTextPattern,
java.lang.Exception i_cause)
Example of defining an exception with cause and the named parameters {inFileName} and {outFileName}:
public static class CopyFailure extends Failure {
public final String inFileName;
public final String outFileName;
public CopyFailure(
final Exception i_cause,
final String i_inFileName,
final String i_outFileName
){
super("File '{inFileName}' could not be copied to '{outFileName}'",i_cause);
inFileName = i_inFileName;
outFileName = i_outFileName;
}
}//CopyFailure
public Failure(java.lang.String i_defaultMessageTextPattern,
java.lang.Exception i_cause,
java.lang.Object[] i_unnamedParameters)
Failure(String,Exception)
In order to shortly create unnamed message parameters, you could use
the convenience class MethodFailure, which passes its unnamed
parameters to the polymorphic Object[] i_unnamedParameters.| Method Detail |
public java.lang.String getDefaultMessageTextPattern()
MsgText.
Locale specific message text patterns are handled by MsgText, too.public final java.lang.Exception cause()
public static final java.lang.Exception cause(java.lang.Throwable i_throwable)
public java.lang.String getMessage()
{name}=myfile.dat {directory}=C:\temp\data {0}=3353 {1}=rw
public void printStackTrace()
Failure
object to the standard error stream System.errprintStackTrace(java.io.PrintWriter),
java.lang.System#errpublic void printStackTrace(java.io.PrintStream io_printer)
Failure
object to io_printer.printStackTrace(java.io.PrintWriter)public void printStackTrace(java.io.PrintWriter io_printer)
Failure
object to io_printer.
The output contains the name, message parameters and stack trace first of
the causing Exception object, then of this Failure
object to the specified print writer. Users should usually not call this
method directly, but Msg.printStackTrace(java.lang.Throwable) instead, in order to avoid
redundant and useless lines in the stack traces.
public static void printCompactStackTrace(java.lang.StringBuffer io_buffer,
java.lang.Throwable i_reportee,
java.lang.Exception i_here)
io_printer - Where to print the compactified stack tracei_reportee - The exception to report, possibly containing a chain of
nested cause exceptionsi_here - An dummy exception, which should have been newly created there,
where the reporting for i_reportee is invokedMsg.report(java.awt.Frame,Throwable)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||