01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.commons.fileupload;
18:
19: import java.io.PrintStream;
20: import java.io.PrintWriter;
21:
22: /**
23: * Exception for errors encountered while processing the request.
24: *
25: * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
26: * @version $Id: FileUploadException.java 479484 2006-11-27 01:06:53Z jochen $
27: */
28: public class FileUploadException extends Exception {
29: /**
30: * Serial version UID, being used, if the exception
31: * is serialized.
32: */
33: private static final long serialVersionUID = 8881893724388807504L;
34: /**
35: * The exceptions cause. We overwrite the cause of
36: * the super class, which isn't available in Java 1.3.
37: */
38: private final Throwable cause;
39:
40: /**
41: * Constructs a new <code>FileUploadException</code> without message.
42: */
43: public FileUploadException() {
44: this (null, null);
45: }
46:
47: /**
48: * Constructs a new <code>FileUploadException</code> with specified detail
49: * message.
50: *
51: * @param msg the error message.
52: */
53: public FileUploadException(final String msg) {
54: this (msg, null);
55: }
56:
57: /**
58: * Creates a new <code>FileUploadException</code> with the given
59: * detail message and cause.
60: * @param msg The exceptions detail message.
61: * @param cause The exceptions cause.
62: */
63: public FileUploadException(String msg, Throwable cause) {
64: super (msg);
65: this .cause = cause;
66: }
67:
68: /**
69: * Prints this throwable and its backtrace to the specified print stream.
70: *
71: * @param stream <code>PrintStream</code> to use for output
72: */
73: public void printStackTrace(PrintStream stream) {
74: super .printStackTrace(stream);
75: if (cause != null) {
76: stream.println("Caused by:");
77: cause.printStackTrace(stream);
78: }
79: }
80:
81: /**
82: * Prints this throwable and its backtrace to the specified
83: * print writer.
84: *
85: * @param writer <code>PrintWriter</code> to use for output
86: */
87: public void printStackTrace(PrintWriter writer) {
88: super .printStackTrace(writer);
89: if (cause != null) {
90: writer.println("Caused by:");
91: cause.printStackTrace(writer);
92: }
93: }
94: }
|