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;
20
21
22 /**
23 * This class is used to represent a variety of exceptions 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 *
50 * @param message the exception error message
51 */
52 public IssueException(String message) {
53 super(message);
54 type = TYPE_UNKNOWN;
55 }
56
57 /**
58 * Creates a new IssueException of unknown type with a default message.
59 *
60 * @param message the exception error message
61 */
62 public IssueException(String message, Throwable cause) {
63 super(message, cause);
64 type = TYPE_UNKNOWN;
65 }
66
67 /**
68 * Creates a new IssueException of specified type with a default message.
69 *
70 * @param message the exception error message
71 * @param type the exception type represented by a resource bundle key
72 */
73 public IssueException(String message, String type) {
74 super(message);
75 this.type = type;
76 }
77
78 /**
79 * Creates a new IssueException of specified type with a default message.
80 *
81 * @param message the exception error message
82 * @param type the exception type represented by a resource bundle key
83 */
84 public IssueException(String message, String type, Throwable cause) {
85 super(message, cause);
86 this.type = type;
87 }
88
89 /**
90 * Returns the exception type which can be used to format a localized
91 * error message.
92 *
93 * @return String resource bundle key representing the exception type.
94 */
95 public String getType() {
96 return type;
97 }
98
99 /**
100 * Sets the issue exception type.
101 *
102 * @param value a String code representing the type of issue exception
103 * that occured.
104 */
105 public void setType(String value) {
106 type = value;
107 }
108 }
109
110