View Javadoc
1   //
2   // $Id$
3   //
4   // jupload - A file upload applet.
5   //
6   // Copyright 2010 The JUpload Team
7   //
8   // Created: 12 fevr. 2010
9   // Creator: etienne_sf
10  // Last modified: $Date$
11  //
12  // This program is free software; you can redistribute it and/or modify
13  // it under the terms of the GNU General Public License as published by
14  // the Free Software Foundation; either version 2 of the License, or
15  // (at your option) any later version.
16  //
17  // This program is distributed in the hope that it will be useful,
18  // but WITHOUT ANY WARRANTY; without even the implied warranty of
19  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  // GNU General Public License for more details.
21  //
22  // You should have received a copy of the GNU General Public License
23  // along with this program; if not, write to the Free Software
24  // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  
26  package wjhk.jupload2.exception;
27  
28  import wjhk.jupload2.policies.UploadPolicy;
29  
30  /**
31   * This error is thrown, when the socket used to read bytes from the server is
32   * closed. Previously, the applet would throw an 'unexpected EOF' error, in this
33   * case.
34   * 
35   * @author etienne_sf
36   */
37  @SuppressWarnings("serial")
38  public class JUploadEOFException extends JUploadIOException {
39  
40      UploadPolicy uploadPolicy;
41  
42      String actionInError = null;
43  
44      /**
45       * @param uploadPolicy
46       * @param actionInError
47       */
48      public JUploadEOFException(UploadPolicy uploadPolicy, String actionInError) {
49          super("Unexpected end of communication with the server");
50          this.uploadPolicy = uploadPolicy;
51          this.actionInError = actionInError;
52      }
53  
54      /**
55       * @return The error messsage. When debug level is 30 or more, the
56       *         actionInError is added to the error message.
57       * 
58       */
59      public String getMessage() {
60          if (this.uploadPolicy.getDebugLevel() >= 30) {
61              return super.getMessage();
62          } else {
63              return super.getMessage() + " (" + this.actionInError + ")";
64          }
65      }
66  }