01: /**
02: * Copyright 2004-2005 jManage.org
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: */package org.jmanage.core.services;
16:
17: import org.jmanage.core.util.ErrorCatalog;
18:
19: /**
20: *
21: * date: Feb 4, 2005
22: * @author Rakesh Kalra
23: */
24: public class ServiceException extends RuntimeException {
25:
26: private String errorCode;
27: private transient Object[] values;
28: private String message;
29:
30: public ServiceException(String errorCode) {
31: this (errorCode, (Object[]) null);
32: }
33:
34: public ServiceException(String errorCode, Object value0) {
35: this (errorCode, new Object[] { value0 });
36: }
37:
38: public ServiceException(String errorCode, Object value0,
39: Object value1) {
40: this (errorCode, new Object[] { value0, value1 });
41: }
42:
43: public ServiceException(String errorCode, Object value0,
44: Object value1, Object value2) {
45: this (errorCode, new Object[] { value0, value1, value2 });
46: }
47:
48: public ServiceException(String errorCode, Object[] 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 getErrorCode() {
56: return errorCode;
57: }
58:
59: public String 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 toString() {
69: return getMessage();
70: }
71: }
|