1 /*
2 * Copyright 2007-2008 Naoki NOSE.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package jp.liq.container.reflect;
17
18 import jp.liq.container.util.AbstractException;
19
20 /**
21 * リフレクション APIの操作中に発生した例外をラップする。
22 * @author nose
23 */
24 public class ReflectException extends AbstractException {
25 private static final long serialVersionUID = -2406215957713803677L;
26
27 /**
28 * 発生した例外の種別を示す。
29 * @author nose
30 */
31 public static enum Reason {
32 /**
33 * コンストラクタの呼び出しに失敗。
34 */
35 FAILED_TO_INVOKE_CONSTRUCTOR,
36 /**
37 * メソッドの呼び出しに失敗。
38 */
39 FAILED_TO_INVOKE_METHOD,
40 /**
41 * フィールドへの値の設定に失敗。
42 */
43 FAILED_TO_SET_FIELD,
44 /**
45 * フィールドからの値の読み込みに失敗。
46 */
47 FAILED_TO_GET_FIELD,
48 FAILED_TO_OPEN_URL,
49 FAILED_TO_READ_CLASS;
50 }
51
52 /**
53 * この例外のインスタンスを構築します。
54 * @param cause 起因例外。
55 * @param target 例外を起こしたリフレクションAPI のラッパ
56 * @param reason 例外の理由。
57 */
58 public ReflectException(Throwable cause, Member target, Reason reason) {
59 super(cause, reason, target);
60 }
61
62 public ReflectException(Throwable cause, Enum<?> errCode, Object... args) {
63 super(cause, errCode, args);
64 }
65
66 public ReflectException(Throwable cause) {
67 super(cause);
68 }
69 }