|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
org.apache.commons.lang.exception.NestableException
他の例外を内部に持つことのできる全ての例外のベースクラスです。
この例外が投げられた原因となる例外の情報を保持することにより、デバッグを容易にすることを意図しています。
例外のキャッチと再度投げられる処理はさまざまなタイミングで起き、
最初に発生した物意外は NestedException の子孫となります。
最終的に printStackTrace() メソッドを使用して出力されるときには
スタックトレースには全ての例外の情報が含まれます。
NestedException, when the
exception is finally printed out using any of the
printStackTrace() methods, the stacktrace will contain
the information about all exceptions thrown and caught on
the way.以下のプログラムを実行してください
1 import org.apache.commons.NestedException;
2
3 public class Test {
4 public static void main( String[] args ) {
5 try {
6 a();
7 } catch(Exception e) {
8 e.printStackTrace();
9 }
10 }
11
12 public static void a() throws Exception {
13 try {
14 b();
15 } catch(Exception e) {
16 throw new NestedException("foo", e);
17 }
18 }
19
20 public static void b() throws Exception {
21 try {
22 c();
23 } catch(Exception e) {
24 throw new NestedException("bar", e);
25 }
26 }
27
28 public static void c() throws Exception {
29 throw new Exception("baz");
30 }
31 }
以下のスタックトレースが出力されます:
java.lang.Exception: baz: bar: foo
at Test.c(Test.java:29)
at Test.b(Test.java:22)
rethrown as NestedException: bar
at Test.b(Test.java:24)
at Test.a(Test.java:14)
rethrown as NestedException: foo
at Test.a(Test.java:16)
at Test.main(Test.java:6)
| フィールドの概要 | |
private Throwable |
cause
この例外が投げられる原因となった例外またはエラーの参照を保持します。 |
protected NestableDelegate |
delegate
委譲された多くの処理をもつヘルパーインスタンス。 |
| クラス java.lang.Exception から継承したフィールド |
|
| クラス java.lang.Throwable から継承したフィールド |
|
| コンストラクタの概要 | |
NestableException()
詳細メッセージを設定せずに新たな NestableException を生成します。
|
|
NestableException(String msg)
詳細メッセージを設定して新たな NestableException を生成します。
|
|
NestableException(String msg,
Throwable cause)
詳細メッセージと原因となる Throwable
を設定して新たな NestableException を生成します。
|
|
NestableException(Throwable cause)
原因となる Throwable を設定して新たな NestableException を生成します。
|
|
| メソッドの概要 | |
Throwable |
getCause()
Nestable が実装された例外の原因となった例外またはエラーの参照を返します。
|
String |
getMessage()
この例外とネストされた Throwable のエラーメッセージを返します。
|
String |
getMessage(int index)
内部に保持されている Throwable のうち、0 から始まる指定されたインデックスに該当する
Throwable のメッセージを返します。
|
String[] |
getMessages()
この例外と内部にネストされる Throwable のエラーメッセージをStringの配列に格納して返します。
|
Throwable |
getThrowable(int index)
内部に保持されている Throwable のうち、0 から始まる指定されたインデックスに該当する
Throwable を返します。
|
int |
getThrowableCount()
この Nestable に含まれるネストされた Throwable の数を返します。
|
Throwable[] |
getThrowables()
この Nestable と、内部にネストされた Throwable
を Throwable の配列に格納して返します。
|
int |
indexOfThrowable(Class type)
内部にネストされた Throwable の中から、最初に見つかった指定された型の 0 から始まるインデックスを返します。
|
int |
indexOfThrowable(Class type,
int fromIndex)
内部にネストされた Throwable から、最初に見つかった指定された型の、検索開始位置より後ろの
0 から始まるインデックスを返します。
|
void |
printPartialStackTrace(PrintWriter out)
指定された writer に対してルートとなる(ネストされたものを含まない)例外のスタックトレースを出力します。 |
void |
printStackTrace()
|
void |
printStackTrace(PrintStream out)
指定された print stream に対してこの例外のスタックトレースを出力します。 |
void |
printStackTrace(PrintWriter out)
指定された print writer に対してこの例外のスタックトレースを出力します。 |
| クラス java.lang.Throwable から継承したメソッド |
fillInStackTrace, getLocalizedMessage, getStackTrace, initCause, setStackTrace, toString |
| クラス java.lang.Object から継承したメソッド |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| フィールドの詳細 |
protected NestableDelegate delegate
private Throwable cause
| コンストラクタの詳細 |
public NestableException()
NestableException を生成します。
NestableException without specified
detail message.
public NestableException(String msg)
NestableException を生成します。
NestableException with specified
detail message.
msg - エラーメッセージ
public NestableException(Throwable cause)
Throwable を設定して新たな NestableException を生成します。
NestableException with specified
nested Throwable.
cause - この例外が投げられる原因となった例外またはエラー
public NestableException(String msg,
Throwable cause)
Throwable
を設定して新たな NestableException を生成します。
NestableException with specified
detail message and nested Throwable.
msg - エラーメッセージ
cause - この例外が投げられる原因となった例外またはエラー
| メソッドの詳細 |
public Throwable getCause()
Nestable の記述: Nestable が実装された例外の原因となった例外またはエラーの参照を返します。
Nestable to be thrown.
Nestable 内の getCausepublic String getMessage()
Nestable の記述: Throwable のエラーメッセージを返します。
Throwable.
Nestable 内の getMessagepublic String getMessage(int index)
Nestable の記述: Throwable のうち、0 から始まる指定されたインデックスに該当する
Throwable のメッセージを返します。
Throwable in the chain
of Throwables at the specified index, numbererd from 0.
Nestable 内の getMessageindex - 内部に保持されている Throwable のインデックス
Throwable in the chain of
ThrowablesThrowable
にメッセージが設定されていない場合には null
Throwable at the
specified index in the chain does not contain a messagepublic String[] getMessages()
Nestable の記述: Throwable のエラーメッセージをStringの配列に格納して返します。
メッセージを持たない Throwable のメッセージは null で表現されます。
返される配列の長さは原因の数を示す Nestable.getThrowableCount() の返す値と一致します。
Throwables
in an array of Strings, one element for each message. Any
Throwable not containing a message is represented in the
array by a null. This has the effect of cause the length of the returned
array to be equal to the result of the {@link #getThrowableCount()}
operation.
Nestable 内の getMessagespublic Throwable getThrowable(int index)
Nestable の記述: Throwable のうち、0 から始まる指定されたインデックスに該当する
Throwable を返します。
Throwable in the chain of
Throwables at the specified index, numbererd from 0.
Nestable 内の getThrowableindex - 内部に保持される Throwable の 0 から始まるインデックス
Throwable in
the chain of ThrowablesThrowable
Throwablepublic int getThrowableCount()
Nestable の記述: Nestable に含まれるネストされた Throwable の数を返します。
Throwables represented by
this Nestable, including this Nestable.
Nestable 内の getThrowableCountpublic Throwable[] getThrowables()
Nestable の記述: Nestable と、内部にネストされた Throwable
を Throwable の配列に格納して返します。
Nestable and any nested Throwables
in an array of Throwables, one element for each
Throwable.
Nestable 内の getThrowablesThrowable の配列
Throwablespublic int indexOfThrowable(Class type)
Nestable の記述: Throwable の中から、最初に見つかった指定された型の 0 から始まるインデックスを返します。
該当するものが見つからなかった場合には -1 を返します。
Throwable Throwables, or -1 if the
specified type is not found in the chain.
Nestable 内の indexOfThrowabletype - 検索対象となる Class
Class to be found
public int indexOfThrowable(Class type,
int fromIndex)
Nestable の記述: Throwable から、最初に見つかった指定された型の、検索開始位置より後ろの
0 から始まるインデックスを返します。
該当するものが見つからなかった場合には -1 を返します。
Throwable
that matches the specified type in the chain of Throwables
with an index greater than or equal to the specified index, or -1 if
the type is not found.
Nestable 内の indexOfThrowabletype - 検索対象となる Class
Class to be foundfromIndex - 検索の開始位置となる 0 から始まるインデックス
public void printStackTrace()
public void printStackTrace(PrintStream out)
Nestable の記述:
Nestable 内の printStackTracepublic void printStackTrace(PrintWriter out)
Nestable の記述:
Nestable 内の printStackTracepublic final void printPartialStackTrace(PrintWriter out)
Nestable の記述: NestableDelegate
から、個々のスタックトレースをバッファに出力するために使用されます。
このメソッドの実装は大体の場合 super.printStackTrace(out); を呼ぶべきです。
super.printStackTrace(out); in most cases.
Nestable 内の printPartialStackTraceout - 使用される writer
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||