KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > services > ServiceException


1 /**
2  * Copyright 2004-2005 jManage.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.jmanage.core.services;
17
18 import org.jmanage.core.util.ErrorCatalog;
19
20 /**
21  *
22  * date: Feb 4, 2005
23  * @author Rakesh Kalra
24  */

25 public class ServiceException extends RuntimeException JavaDoc {
26
27     private String JavaDoc errorCode;
28     private transient Object JavaDoc[] values;
29     private String JavaDoc message;
30
31     public ServiceException(String JavaDoc errorCode){
32         this(errorCode, (Object JavaDoc[])null);
33     }
34
35     public ServiceException(String JavaDoc errorCode, Object JavaDoc value0){
36         this(errorCode, new Object JavaDoc[]{value0});
37     }
38
39     public ServiceException(String JavaDoc errorCode, Object JavaDoc value0, Object JavaDoc value1){
40         this(errorCode, new Object JavaDoc[]{value0, value1});
41     }
42
43     public ServiceException(String JavaDoc errorCode, Object JavaDoc value0, Object JavaDoc value1,
44                             Object JavaDoc value2){
45         this(errorCode, new Object JavaDoc[]{value0, value1, value2});
46     }
47
48     public ServiceException(String JavaDoc errorCode, Object JavaDoc[] values){
49         assert errorCode != null;
50         this.errorCode = errorCode;
51         this.values = values;
52         this.message = ErrorCatalog.getMessage(errorCode, values);
53     }
54
55     public String JavaDoc getErrorCode(){
56         return errorCode;
57     }
58
59     public String JavaDoc getMessage(){
60         return message;
61     }
62
63     /**
64      * TODO: remove
65      * This is overridden as Apache XmlRpc calls this method to get
66      * error message.
67      */

68     public String JavaDoc toString(){
69         return getMessage();
70     }
71 }
72
Popular Tags