PageRenderTime 56ms CodeModel.GetById 20ms app.highlight 15ms RepoModel.GetById 15ms app.codeStats 0ms

/src/main/java/com/google/ie/common/exception/IdeasExchangeException.java

http://thoughtsite.googlecode.com/
Java | 98 lines | 26 code | 13 blank | 59 comment | 1 complexity | c582849928e7df98f8d3fbf51fb1cae2 MD5 | raw file
 1/* Copyright 2010 Google Inc.
 2 * 
 3 * Licensed under the Apache License, Version 2.0 (the "License");
 4 * you may not use this file except in compliance with the License.
 5 * You may obtain a copy of the License at
 6 * 
 7 *      http://www.apache.org/licenses/LICENSE-2.0
 8 * 
 9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS.
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License
14 */
15
16package com.google.ie.common.exception;
17
18/**
19 * An Object that extends the Exception object.
20 * This class is used to wrap all business exceptions that can occur in the
21 * Ideas Exchange project.
22 * 
23 * 
24 * @author asirohi
25 * 
26 */
27public class IdeasExchangeException extends Exception {
28
29    /** A unique identifier for the class */
30    private static final long serialVersionUID = -6759584646737468342L;
31
32    /** An error code that is used to display locale specific error messages */
33    private String errorCode;
34
35    /**
36     * Constructs a new {@link IdeasExchangeException} object with the specified
37     * detail message and an error code.
38     * 
39     * @param errorCode string representing a specific code for the exception.
40     * @param message string containing the detail message.
41     */
42    public IdeasExchangeException(String errorCode, String message) {
43        this(errorCode, message, null);
44    }
45
46    /**
47     * Constructs a new {@link IdeasExchangeException} object with the specified
48     * error code and cause.
49     * 
50     * @param errorCode an error code of the exception.
51     * @param message the detail message of the exception.
52     */
53    public IdeasExchangeException(String errorCode, Throwable cause) {
54        this(errorCode, null, cause);
55    }
56
57    /**
58     * Constructs a new {@link IdeasExchangeException} object with the specified
59     * error code,message and cause.
60     * 
61     * @param errorCode an error code of the exception.
62     * @param message the detail message of the exception.
63     * @param cause an object of class {@link Throwable} representing the cause
64     *        (which is saved for later retrieval by the Throwable.getCause()
65     *        method).
66     */
67
68    public IdeasExchangeException(String errorCode, String message, Throwable cause) {
69        super(message, cause);
70        this.errorCode = errorCode;
71    }
72
73    /**
74     * Return the error code of the error
75     * 
76     * @return String
77     */
78    public String getErrorCode() {
79        return errorCode;
80    }
81
82    /**
83     * Set the error code.
84     * 
85     * @param errorCode
86     */
87    public void setErrorCode(String errorCode) {
88        this.errorCode = errorCode;
89    }
90
91    @Override
92    public String toString() {
93        String s = super.toString();
94        return (errorCode != null) ? (errorCode + " : " + s) : s;
95    }
96
97}
98