01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.service;
19:
20: import java.util.LinkedList;
21: import java.util.List;
22: import java.util.Map;
23:
24: import org.ofbiz.base.util.Debug;
25:
26: /**
27: * General Service Exception - base Exception for in-Service Errors
28: */
29: public class GeneralServiceException extends
30: org.ofbiz.base.util.GeneralException {
31:
32: protected List errorMsgList = null;
33: protected Map errorMsgMap = null;
34: protected Map nestedServiceResult = null;
35:
36: public GeneralServiceException() {
37: super ();
38: }
39:
40: public GeneralServiceException(String str) {
41: super (str);
42: }
43:
44: public GeneralServiceException(String str, Throwable nested) {
45: super (str, nested);
46: }
47:
48: public GeneralServiceException(Throwable nested) {
49: super (nested);
50: }
51:
52: public GeneralServiceException(String str, List errorMsgList,
53: Map errorMsgMap, Map nestedServiceResult, Throwable nested) {
54: super (str, nested);
55: this .errorMsgList = errorMsgList;
56: this .errorMsgMap = errorMsgMap;
57: this .nestedServiceResult = nestedServiceResult;
58: }
59:
60: public Map returnError(String module) {
61: String errMsg = this .getMessage() == null ? "Error in Service"
62: : this .getMessage();
63: if (this .getNested() != null) {
64: Debug.logError(this .getNested(), errMsg, module);
65: }
66: return ServiceUtil.returnError(errMsg, this .errorMsgList,
67: this .errorMsgMap, this .nestedServiceResult);
68: }
69:
70: public void addErrorMessages(List errMsgs) {
71: if (this .errorMsgList == null) {
72: this .errorMsgList = new LinkedList();
73: }
74: this.errorMsgList.addAll(errMsgs);
75: }
76: }
|