001 /*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016 package org.opengion.hayabusa.common;
017
018 /**
019 * 共通的に使用されるエクセプションクラスです?
020 *
021 * RuntimeException を継承して?ため、try{} catch() {} は不要です?
022 * 本シス?では、すべてこ?エクセプションクラスを継承させたクラスを作?し?用途によって?
023 * 使??けるようにします?つまり?他?どのような、Throwable が発生したとしても???
024 * try{} catch() {} で受けて、このクラスのサブクラスを?再度 throw させます?
025 * そして、?であれば、try{} catch() {} を用?捕まえて、それぞれ?対応??行います?
026 *
027 * こ?クラスには、???発生したエクセプション( Throwable )を引数にとり?
028 * そ? printStackTrace()??を?自??身のトレース??に含めます?
029 * また?引数にオブジェクトを渡すことができます?で、object.toString() で、オブジェクト?
030 * 状態を表示できるようにしておけば、手軽に??に使?とが可能になります?
031 *
032 * @og.group エラー処?
033 *
034 * @version 4.0
035 * @author Kazuhiko Hasegawa
036 * @since JDK5.0,
037 */
038 public class HybsSystemException extends RuntimeException {
039 private static final long serialVersionUID = 400020050131L ;
040
041 /** シス?依存?改行記号をセ?します? */
042 // private static final String CR = System.getProperty("line.separator");
043
044 /**
045 * 詳細メ?ージを指定しな? HybsSystemException を構築します?
046 *
047 */
048 public HybsSystemException() {
049 // 4.3.4.4 (2009/01/01)
050 // super();
051 }
052
053 /**
054 * ?された詳細メ?ージを持つ HybsSystemException を構築します?
055 *
056 * @param str 詳細メ?ージ
057 */
058 public HybsSystemException( final String str ) {
059 super( str );
060 }
061
062 /**
063 * ?された詳細メ?ージを持つ HybsSystemException を構築します?
064 *
065 * @param th 例外Throwableオブジェク?
066 */
067 public HybsSystemException( final Throwable th ) {
068 super( th );
069 }
070
071 /**
072 * ?されたオブジェクトを受け取る HybsSystemException を構築します?
073 *
074 * @og.rev 3.5.5.4 (2004/04/15) 引数を?RuntimeException(String , Throwable )にあわせます?
075 *
076 * @param str 詳細メ?ージ
077 * @param th 例外Throwableオブジェク?
078 * @see java.lang.RuntimeException#RuntimeException(String,Throwable)
079 */
080 public HybsSystemException( final String str,final Throwable th ) {
081 super( str,th );
082 }
083
084 /**
085 * こ? Throwable オブジェクト?詳細メ?ージ??を返します?
086 * こ?クラスは、発生?の Throwable の StackTrace を?例外チェーン機?
087 * を利用して取得して?す?
088 * また?"org.opengion." を含?タ?トレースのみ、メ?ージとして追?ます?
089 *
090 * @og.rev 4.0.0.0 (2005/01/31) 例外チェーンを遡ってメ?ージを?力します?
091 *
092 * @param thIn Throwableオブジェク?
093 *
094 * @return Throwableの詳細メ?ージ
095 */
096 // public static String getLongMessage( final Throwable thIn ) {
097 // StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
098 // StringBuilder trace = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
099 //
100 // buf.append( CR );
101 // buf.append( "Version :" ).append( BuildNumber.ENGINE_INFO ).append( CR );
102 //
103 // Throwable th = thIn ;
104 // while( th != null ) {
105 // trace = getStackData( trace,th );
106 // if( th instanceof HybsSystemException ) {
107 // buf.append( th.getMessage() );
108 // }
109 // else {
110 // String msg = th.getMessage();
111 // if( msg != null && buf.indexOf( msg ) < 0 ) {
112 // buf.append( msg );
113 // }
114 // }
115 // buf.append( CR );
116 // th = th.getCause();
117 // }
118 //
119 // buf.append( trace.toString() );
120 // return buf.toString();
121 // }
122
123 /**
124 * "org.opengion." を含?StackTraceElement のメ?ージ??を返します?
125 *
126 * @og.rev 4.0.0.0 (2005/01/31) 新規追?
127 *
128 * @param buf StringBuilder 以前?エラーメ?ージ
129 * @param th Throwable スタ?トレースを取り?すThrowableオブジェク?
130 *
131 * @return "org.opengion." を含?StackTraceElement のメ?ージ
132 */
133 // private static StringBuilder getStackData( final StringBuilder buf,final Throwable th ) {
134 // if( th != null ) {
135 // int cnt = 0;
136 // StackTraceElement[] trace = th.getStackTrace();
137 // for( int i=0; i<trace.length; i++ ) {
138 // String msg = trace[i].toString();
139 // if( buf.indexOf( msg ) < 0 ) {
140 // if( msg != null && msg.indexOf( "org.opengion." ) >= 0 ) {
141 // buf.append( "\tat " ).append( msg ).append( CR );
142 // }
143 // else if( cnt++ < 5 ) {
144 // buf.append( "\tat " ).append( msg ).append( CR );
145 // }
146 // else if( cnt++ == 5 ) {
147 // buf.append( "\t ......" ).append( CR );
148 // }
149 // }
150 // }
151 // buf.append( "\t ... more ..." ).append( CR );
152 // }
153 // return buf;
154 // }
155 }