2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.cloudify.exceptions;
23 import org.onap.so.openstack.exceptions.MsoException;
24 import org.onap.so.openstack.exceptions.MsoExceptionCategory;
27 * OpenStack exception.
29 public class MsoCloudifyException extends MsoException {
34 private static final long serialVersionUID = 3313636124141766495L;
36 private int statusCode;
37 private String statusMessage;
38 private String errorDetail;
39 private boolean pendingWorkflow;
42 * Constructor to create a new MsoOpenstackException instance
44 * @param code the error code
45 * @param message the error message
46 * @param detail error details
48 public MsoCloudifyException(int code, String message, String detail) {
49 // Set the detailed error as the Exception 'message'
51 super.category = MsoExceptionCategory.OPENSTACK;
53 this.statusCode = code;
54 this.statusMessage = message;
55 this.errorDetail = detail;
56 this.pendingWorkflow = false;
60 * Constructor to propagate the caught exception (mostly for stack trace)
62 * @param code the error code
63 * @param message the error message
64 * @param detail error details
67 public MsoCloudifyException(int code, String message, String detail, Exception e) {
68 // Set the detailed error as the Exception 'message'
70 super.category = MsoExceptionCategory.OPENSTACK;
72 this.statusCode = code;
73 this.statusMessage = message;
74 this.errorDetail = detail;
75 this.pendingWorkflow = false;
78 public void setPendingWorkflow(boolean pendingWorkflow) {
79 this.pendingWorkflow = pendingWorkflow;
83 public String toString() {
84 String error = "" + statusCode + " " + statusMessage + ": " + errorDetail
85 + (pendingWorkflow ? " [workflow pending]" : "");