source: josm/trunk/src/com/drew/lang/CompoundException.java@ 7299

Last change on this file since 7299 was 6127, checked in by bastiK, 12 years ago

applied #8895 - Upgrade metadata-extractor to v. 2.6.4 (patch by ebourg)

File size: 3.0 KB
RevLine 
[4231]1/*
[6127]2 * Copyright 2002-2012 Drew Noakes
[4231]3 *
[6127]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
[4231]7 *
[6127]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/
[4231]20 */
21package com.drew.lang;
22
[6127]23import com.drew.lang.annotations.NotNull;
24import com.drew.lang.annotations.Nullable;
25
[4231]26import java.io.PrintStream;
27import java.io.PrintWriter;
28
29/**
30 * Represents a compound exception, as modelled in JDK 1.4, but
31 * unavailable in previous versions. This class allows support
32 * of these previous JDK versions.
[6127]33 *
34 * @author Drew Noakes http://drewnoakes.com
[4231]35 */
36public class CompoundException extends Exception
37{
[6127]38 private static final long serialVersionUID = -9207883813472069925L;
[4231]39
[6127]40 @Nullable
41 private final Throwable _innerException;
42
43 public CompoundException(@Nullable String msg)
[4231]44 {
45 this(msg, null);
46 }
47
[6127]48 public CompoundException(@Nullable Throwable exception)
[4231]49 {
50 this(null, exception);
51 }
52
[6127]53 public CompoundException(@Nullable String msg, @Nullable Throwable innerException)
[4231]54 {
55 super(msg);
[6127]56 _innerException = innerException;
[4231]57 }
58
[6127]59 @Nullable
[4231]60 public Throwable getInnerException()
61 {
[6127]62 return _innerException;
[4231]63 }
64
[6127]65 @NotNull
[4231]66 public String toString()
67 {
[6127]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());
[4231]75 }
[6127]76 return string.toString();
[4231]77 }
78
[6127]79 public void printStackTrace(@NotNull PrintStream s)
[4231]80 {
81 super.printStackTrace(s);
[6127]82 if (_innerException != null) {
[4231]83 s.println("--- inner exception ---");
[6127]84 _innerException.printStackTrace(s);
[4231]85 }
86 }
87
[6127]88 public void printStackTrace(@NotNull PrintWriter s)
[4231]89 {
90 super.printStackTrace(s);
[6127]91 if (_innerException != null) {
[4231]92 s.println("--- inner exception ---");
[6127]93 _innerException.printStackTrace(s);
[4231]94 }
95 }
96
97 public void printStackTrace()
98 {
99 super.printStackTrace();
[6127]100 if (_innerException != null) {
[4231]101 System.err.println("--- inner exception ---");
[6127]102 _innerException.printStackTrace();
[4231]103 }
104 }
105}
Note: See TracBrowser for help on using the repository browser.