Changeset 6127 in josm for trunk/src/com/drew/lang/CompoundException.java
- Timestamp:
- 2013-08-09T18:05:11+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/lang/CompoundException.java
r4231 r6127 1 1 /* 2 * This is public domain software - that is, you can do whatever you want 3 * with it, and include it software that is licensed under the GNU or the 4 * BSD license, or whatever other licence you choose, including proprietary 5 * closed source licenses. I do ask that you leave this header in tact. 2 * Copyright 2002-2012 Drew Noakes 6 3 * 7 * If you make modifications to this code that you think would benefit the 8 * wider community, please send me a copy and I'll post it on my site. 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 9 7 * 10 * If you make use of this code, I'd appreciate hearing about it. 11 * drew@drewnoakes.com 12 * Latest version of this software kept at 13 * http://drewnoakes.com/ 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 * More information about this project is available at: 17 * 18 * http://drewnoakes.com/code/exif/ 19 * http://code.google.com/p/metadata-extractor/ 14 20 */ 15 21 package com.drew.lang; 22 23 import com.drew.lang.annotations.NotNull; 24 import com.drew.lang.annotations.Nullable; 16 25 17 26 import java.io.PrintStream; … … 22 31 * unavailable in previous versions. This class allows support 23 32 * of these previous JDK versions. 33 * 34 * @author Drew Noakes http://drewnoakes.com 24 35 */ 25 36 public class CompoundException extends Exception 26 37 { 27 private final Throwable _innnerException;38 private static final long serialVersionUID = -9207883813472069925L; 28 39 29 public CompoundException(String msg) 40 @Nullable 41 private final Throwable _innerException; 42 43 public CompoundException(@Nullable String msg) 30 44 { 31 45 this(msg, null); 32 46 } 33 47 34 public CompoundException(Throwable exception) 48 public CompoundException(@Nullable Throwable exception) 35 49 { 36 50 this(null, exception); 37 51 } 38 52 39 public CompoundException(String msg, Throwable innerException) 53 public CompoundException(@Nullable String msg, @Nullable Throwable innerException) 40 54 { 41 55 super(msg); 42 _inn nerException = innerException;56 _innerException = innerException; 43 57 } 44 58 59 @Nullable 45 60 public Throwable getInnerException() 46 61 { 47 return _inn nerException;62 return _innerException; 48 63 } 49 64 65 @NotNull 50 66 public String toString() 51 67 { 52 StringBu ffer sbuffer= new StringBuffer();53 s buffer.append(super.toString());54 if (_inn nerException != null) {55 s buffer.append("\n");56 s buffer.append("--- inner exception ---");57 s buffer.append("\n");58 s buffer.append(_innnerException.toString());68 StringBuilder string = new StringBuilder(); 69 string.append(super.toString()); 70 if (_innerException != null) { 71 string.append("\n"); 72 string.append("--- inner exception ---"); 73 string.append("\n"); 74 string.append(_innerException.toString()); 59 75 } 60 return s buffer.toString();76 return string.toString(); 61 77 } 62 78 63 public void printStackTrace(PrintStream s) 79 public void printStackTrace(@NotNull PrintStream s) 64 80 { 65 81 super.printStackTrace(s); 66 if (_inn nerException != null) {82 if (_innerException != null) { 67 83 s.println("--- inner exception ---"); 68 _inn nerException.printStackTrace(s);84 _innerException.printStackTrace(s); 69 85 } 70 86 } 71 87 72 public void printStackTrace(PrintWriter s) 88 public void printStackTrace(@NotNull PrintWriter s) 73 89 { 74 90 super.printStackTrace(s); 75 if (_inn nerException != null) {91 if (_innerException != null) { 76 92 s.println("--- inner exception ---"); 77 _inn nerException.printStackTrace(s);93 _innerException.printStackTrace(s); 78 94 } 79 95 } … … 82 98 { 83 99 super.printStackTrace(); 84 if (_inn nerException != null) {100 if (_innerException != null) { 85 101 System.err.println("--- inner exception ---"); 86 _inn nerException.printStackTrace();102 _innerException.printStackTrace(); 87 103 } 88 104 }
Note:
See TracChangeset
for help on using the changeset viewer.