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 * @og.rev 5.6.7.1 (2013/08/09) エラーに、エンジンのバ?ジョン等?シス?関係???を付与します?
034 *
035 * @version 4.0
036 * @author Kazuhiko Hasegawa
037 * @since JDK5.0,
038 */
039 public class HybsSystemException extends RuntimeException {
040 private static final long serialVersionUID = 567120130809L ;
041
042 /** シス?依存?改行記号をセ?します? */
043 private static final String CR = System.getProperty("line.separator");
044
045 /** ?タブ?代わりのスペ?ス */
046 private static final String TAB = " " ;
047
048 /** エラーメ?ージに付与するシス?関係??? 5.6.7.3 (2013/08/23) */
049 private static final String ERR_INFO =
050 " -------- Exception Information ---------" + CR
051 + TAB + HybsSystem.sys( "OS_INFO" ) + CR // Windows 7 Service Pack 1
052 + TAB + HybsSystem.sys( "SERVER_INFO" ) + CR // 10374232-0004 ( 200.1.50.239 )
053 + TAB + HybsSystem.sys( "SERVLET_INFO" ) + CR // Apache Tomcat/7.0.42
054 + TAB + TAB + HybsSystem.sys( "TOMCAT_HOME" ) + CR // C:/opengionV6/uap/bin/../../apps/tomcat7.0.42
055 + TAB + HybsSystem.sys( "JDK_INFO" ) + CR // Java HotSpot(TM) Server VM 23.25-b01
056 + TAB + TAB + HybsSystem.sys( "JAVA_HOME" ) + CR // H:/java/tomcat5.5.17
057 + TAB + HybsSystem.sys( "ENGINE_INFO" ) + CR // 5.6.6.0 Release5 Builds (2013182)
058 + TAB + TAB + HybsSystem.sys( "REAL_PATH" ) // C:/opengionV6/uap/webapps/gf/
059 + TAB + "(" + HybsSystem.sys( "SYSTEM_ID" ) + ")" + CR // GF
060 + " ----------------------------------------" + CR ;
061
062 /**
063 * 詳細メ?ージを指定しな? HybsSystemException を構築します?
064 *
065 * @og.rev 5.6.7.1 (2013/08/09) エラーに、エンジンのバ?ジョン等???を付与します?
066 */
067 public HybsSystemException() {
068 // 4.3.4.4 (2009/01/01)
069 // super();
070 System.err.println( ERR_INFO );
071 }
072
073 /**
074 * ?された詳細メ?ージを持つ HybsSystemException を構築します?
075 *
076 * @og.rev 5.6.7.1 (2013/08/09) エラーに、エンジンのバ?ジョン等???を付与します?
077 *
078 * @param str 詳細メ?ージ
079 */
080 public HybsSystemException( final String str ) {
081 super( str );
082 System.err.println( ERR_INFO );
083 }
084
085 /**
086 * ?された詳細メ?ージを持つ HybsSystemException を構築します?
087 *
088 * @og.rev 5.6.7.1 (2013/08/09) エラーに、エンジンのバ?ジョン等???を付与します?
089 *
090 * @param th 例外Throwableオブジェク?
091 */
092 public HybsSystemException( final Throwable th ) {
093 super( th );
094 System.err.println( ERR_INFO );
095 }
096
097 /**
098 * ?されたオブジェクトを受け取る HybsSystemException を構築します?
099 *
100 * @og.rev 3.5.5.4 (2004/04/15) 引数を?RuntimeException(String , Throwable )にあわせます?
101 * @og.rev 5.6.7.1 (2013/08/09) エラーに、エンジンのバ?ジョン等???を付与します?
102 *
103 * @param str 詳細メ?ージ
104 * @param th 例外Throwableオブジェク?
105 * @see java.lang.RuntimeException#RuntimeException(String,Throwable)
106 */
107 public HybsSystemException( final String str,final Throwable th ) {
108 super( str,th );
109 System.err.println( ERR_INFO );
110 }
111
112 /**
113 * こ? Throwable オブジェクト?詳細メ?ージ??を返します?
114 * こ?クラスは、発生?の Throwable の StackTrace を?例外チェーン機?
115 * を利用して取得して?す?
116 * また?"org.opengion." を含?タ?トレースのみ、メ?ージとして追?ます?
117 *
118 * @og.rev 4.0.0.0 (2005/01/31) 例外チェーンを遡ってメ?ージを?力します?
119 *
120 * @param thIn Throwableオブジェク?
121 *
122 * @return Throwableの詳細メ?ージ
123 */
124 // public static String getLongMessage( final Throwable thIn ) {
125 // StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
126 // StringBuilder trace = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
127 //
128 // buf.append( CR );
129 // buf.append( "Version :" ).append( BuildNumber.ENGINE_INFO ).append( CR );
130 //
131 // Throwable th = thIn ;
132 // while( th != null ) {
133 // trace = getStackData( trace,th );
134 // if( th instanceof HybsSystemException ) {
135 // buf.append( th.getMessage() );
136 // }
137 // else {
138 // String msg = th.getMessage();
139 // if( msg != null && buf.indexOf( msg ) < 0 ) {
140 // buf.append( msg );
141 // }
142 // }
143 // buf.append( CR );
144 // th = th.getCause();
145 // }
146 //
147 // buf.append( trace.toString() );
148 // return buf.toString();
149 // }
150
151 /**
152 * "org.opengion." を含?StackTraceElement のメ?ージ??を返します?
153 *
154 * @og.rev 4.0.0.0 (2005/01/31) 新規追?
155 *
156 * @param buf StringBuilder 以前?エラーメ?ージ
157 * @param th Throwable スタ?トレースを取り?すThrowableオブジェク?
158 *
159 * @return "org.opengion." を含?StackTraceElement のメ?ージ
160 */
161 // private static StringBuilder getStackData( final StringBuilder buf,final Throwable th ) {
162 // if( th != null ) {
163 // int cnt = 0;
164 // StackTraceElement[] trace = th.getStackTrace();
165 // for( int i=0; i<trace.length; i++ ) {
166 // String msg = trace[i].toString();
167 // if( buf.indexOf( msg ) < 0 ) {
168 // if( msg != null && msg.indexOf( "org.opengion." ) >= 0 ) {
169 // buf.append( "\tat " ).append( msg ).append( CR );
170 // }
171 // else if( cnt++ < 5 ) {
172 // buf.append( "\tat " ).append( msg ).append( CR );
173 // }
174 // else if( cnt++ == 5 ) {
175 // buf.append( "\t ......" ).append( CR );
176 // }
177 // }
178 // }
179 // buf.append( "\t ... more ..." ).append( CR );
180 // }
181 // return buf;
182 // }
183 }