PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

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

http://thoughtsite.googlecode.com/
Java | 99 lines | 26 code | 15 blank | 58 comment | 1 complexity | 7e8d1f45b171e81a895163863a3947ed 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 RuntimeException object.
20 * The class is used to wrap the Runtime exceptions that can occur in Ideas
21 * Exchange Project.
22 * 
23 * @author asirohi
24 * 
25 */
26public class SystemException extends RuntimeException {
27
28    /** A unique identifier for the class */
29    private static final long serialVersionUID = -5912342563924088330L;
30
31    /** An error code that is used to display locale specific error messages */
32    private String errorCode;
33
34    /**
35     * Constructs a new {@link SystemException} object with the specified detail
36     * message and an error code.
37     * 
38     * @param errorCode an error code of the exception.
39     * @param message the detail message of the exception.
40     */
41    public SystemException(String errorCode, String message) {
42        this(errorCode, message, null);
43    }
44
45    /**
46     * Constructs a new {@link SystemException} object with the specified error
47     * code and cause.
48     * 
49     * @param errorCode an error code of the exception.
50     * @param message the detail message of the exception.
51     */
52    public SystemException(String errorCode, Throwable cause) {
53        this(errorCode, null, cause);
54    }
55
56    /**
57     * Constructs a new {@link SystemException} object with the specified error
58     * code,message and cause.
59     * 
60     * @param errorCode an error code of the exception.
61     * @param message the detail message of the exception.
62     * @param cause an object of class {@link Throwable} representing the cause
63     *        (which is saved for later retrieval by the Throwable.getCause()
64     *        method).
65     */
66
67    public SystemException(String errorCode, String message, Throwable cause) {
68        super(message, cause);
69        this.errorCode = errorCode;
70    }
71
72    /**
73     * Get error code of the.
74     * 
75     * @return String
76     */
77
78    public String getErrorCode() {
79        return errorCode;
80    }
81
82    /**
83     * Set the error code.
84     * 
85     * @param errorCode
86     */
87
88    public void setErrorCode(String errorCode) {
89        this.errorCode = errorCode;
90    }
91
92    @Override
93    public String toString() {
94        String s = super.toString();
95        return (errorCode != null) ? (errorCode + " : " + s) : s;
96    }
97
98}
99