Path: blob/master/test/jdk/java/rmi/testlibrary/TestFailedException.java
41149 views
/*1* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**/242526/**27* Simple class to wrap test failure exceptions in a RuntimeException.28* Provides a detail exception and a message.29*/30public class TestFailedException extends java.lang.RuntimeException {31public Throwable detail;3233public TestFailedException() {}3435public TestFailedException(String s) {36super(s);37}3839public TestFailedException(String s, Throwable ex) {40super(s);41detail = ex;42}4344public String getMessage() {45if (detail == null)46return super.getMessage();47else48return super.getMessage() +49"; nested exception is: \n\t" +50detail.toString();51}5253public void printStackTrace(java.io.PrintStream ps)54{55if (detail == null) {56super.printStackTrace(ps);57} else {58synchronized(ps) {59ps.println(this);60detail.printStackTrace(ps);61}62}63}6465public void printStackTrace()66{67printStackTrace(System.err);68}6970public void printStackTrace(java.io.PrintWriter pw)71{72if (detail == null) {73super.printStackTrace(pw);74} else {75synchronized(pw) {76pw.println(this);77detail.printStackTrace(pw);78}79}80}81}828384