1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.fileupload;
18
19 import java.io.PrintStream;
20 import java.io.PrintWriter;
21
22
23 /**
24 * Exception for errors encountered while processing the request.
25 *
26 * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
27 * @version $Id: FileUploadException.java 479484 2006-11-27 01:06:53Z jochen $
28 */
29 public class FileUploadException extends Exception {
30 /**
31 * Serial version UID, being used, if the exception
32 * is serialized.
33 */
34 private static final long serialVersionUID = 8881893724388807504L;
35 /**
36 * The exceptions cause. We overwrite the cause of
37 * the super class, which isn't available in Java 1.3.
38 */
39 private final Throwable cause;
40
41 /**
42 * Constructs a new <code>FileUploadException</code> without message.
43 */
44 public FileUploadException() {
45 this(null, null);
46 }
47
48 /**
49 * Constructs a new <code>FileUploadException</code> with specified detail
50 * message.
51 *
52 * @param msg the error message.
53 */
54 public FileUploadException(final String msg) {
55 this(msg, null);
56 }
57
58 /**
59 * Creates a new <code>FileUploadException</code> with the given
60 * detail message and cause.
61 * @param msg The exceptions detail message.
62 * @param cause The exceptions cause.
63 */
64 public FileUploadException(String msg, Throwable cause) {
65 super(msg);
66 this.cause = cause;
67 }
68
69 /**
70 * Prints this throwable and its backtrace to the specified print stream.
71 *
72 * @param stream <code>PrintStream</code> to use for output
73 */
74 public void printStackTrace(PrintStream stream) {
75 super.printStackTrace(stream);
76 if (cause != null) {
77 stream.println("Caused by:");
78 cause.printStackTrace(stream);
79 }
80 }
81
82 /**
83 * Prints this throwable and its backtrace to the specified
84 * print writer.
85 *
86 * @param writer <code>PrintWriter</code> to use for output
87 */
88 public void printStackTrace(PrintWriter writer) {
89 super.printStackTrace(writer);
90 if (cause != null) {
91 writer.println("Caused by:");
92 cause.printStackTrace(writer);
93 }
94 }
95 }