View Javadoc

1   /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10   * the Free Software Foundation; either version 2 of the License, or
11   * (at your option) any later version.
12   *
13   * This program is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   * GNU General Public License for more details.
17   */
18  
19  package org.itracker.services.exceptions;
20  
21  
22  /**
23    * This class is used to represent a variety of execptions that can occur
24    * while processing issues.
25    */
26  public class IssueException extends Exception {
27      
28      /**
29  	 * 
30  	 */
31  	private static final long serialVersionUID = 3433495017849044287L;
32  	public static final String TYPE_UNKNOWN = "itracker.web.error.system";
33  	public static final String TYPE_CF_INVALID_LIST_OPTION = "itracker.web.error.validate.invalid";
34      public static final String TYPE_CF_PARSE_NUM = "itracker.web.error.validate.number";
35      public static final String TYPE_CF_PARSE_DATE = "itracker.web.error.validate.date";
36      public static final String TYPE_CF_REQ_FIELD = "itracker.web.error.validate.required";
37  
38      private String type;
39  
40      /**
41        * Creates a new IssueException of unknown type.
42        */
43      public IssueException() {
44          type = TYPE_UNKNOWN;
45      }
46  
47      /**
48        * Creates a new IssueException of unknown type with a default message.
49        * @param message the exception error message
50        */
51      public IssueException(String message) {
52          super(message);
53          type = TYPE_UNKNOWN;
54      }
55  
56      /**
57        * Creates a new IssueException of unknown type with a default message.
58        * @param message the exception error message
59        */
60      public IssueException(String message, Throwable cause) {
61          super(message, cause);
62          type = TYPE_UNKNOWN;
63      }
64      
65      /**
66        * Creates a new IssueException of specified type with a default message.
67        * @param message the exception error message
68        * @param type the exception type represented by a resource bundle key
69        */
70      public IssueException(String message, String type) {
71          super(message);
72          this.type = type;
73      }
74  
75      /**
76        * Creates a new IssueException of specified type with a default message.
77        * @param message the exception error message
78        * @param type the exception type represented by a resource bundle key
79        */
80      public IssueException(String message, String type, Throwable cause) {
81          super(message, cause);
82          this.type = type;
83      }
84      
85      /**
86        * Returns the exception type which can be used to format a localized
87        * error message.
88        * @return String resource bundle key representing the exception type.
89        */
90      public String getType() {
91          return type;
92      }
93  
94      /**
95        * Sets the issue exception type.
96        * @param value a String code representing the type of issue exception
97        *              that occured.
98        */
99      public void setType(String value) {
100         type = value;
101     }
102 }
103 
104