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 */
016package 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 */
039public 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        /** 4タブの代わりのスペース */
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                System.err.println( ERR_INFO );
070        }
071
072        /**
073         *  指定された詳細メッセージを持つ HybsSystemException を構築します。
074         *
075         * @og.rev 5.6.7.1 (2013/08/09) エラーに、エンジンのバージョン等の情報を付与します。
076         *
077         * @param       str     詳細メッセージ
078         */
079        public HybsSystemException( final String str ) {
080                super( str );
081                System.err.println( ERR_INFO );
082        }
083
084        /**
085         *  指定された詳細メッセージを持つ HybsSystemException を構築します。
086         *
087         * @og.rev 5.6.7.1 (2013/08/09) エラーに、エンジンのバージョン等の情報を付与します。
088         *
089         * @param       th      例外Throwableオブジェクト
090         */
091        public HybsSystemException( final Throwable th ) {
092                super( th );
093                System.err.println( ERR_INFO );
094        }
095
096        /**
097         *  指定されたオブジェクトを受け取る HybsSystemException を構築します。
098         *
099         * @og.rev 3.5.5.4 (2004/04/15) 引数を、RuntimeException(String , Throwable )にあわせます。
100         * @og.rev 5.6.7.1 (2013/08/09) エラーに、エンジンのバージョン等の情報を付与します。
101         *
102         * @param       str     詳細メッセージ
103         * @param       th      例外Throwableオブジェクト
104         * @see         java.lang.RuntimeException#RuntimeException(String,Throwable)
105         */
106        public HybsSystemException( final String str,final Throwable th ) {
107                super( str,th );
108                System.err.println( ERR_INFO );
109        }
110}