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.openecomp.mso.cloudify.exceptions;
23 import org.openecomp.mso.openstack.exceptions.MsoException;
24 import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
27 * OpenStack exception.
29 public class MsoCloudifyException extends MsoException
35 private static final long serialVersionUID = 3313636124141766495L;
37 private int statusCode;
38 private String statusMessage;
39 private String errorDetail;
40 private boolean pendingWorkflow;
43 * 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)
61 * @param code the error code
62 * @param message the error message
63 * @param detail error details
66 public MsoCloudifyException (int code, String message, String detail, Exception e) {
67 // Set the detailed error as the Exception 'message'
69 super.category = MsoExceptionCategory.OPENSTACK;
71 this.statusCode = code;
72 this.statusMessage = message;
73 this.errorDetail = detail;
74 this.pendingWorkflow = false;
77 public void setPendingWorkflow (boolean pendingWorkflow) {
78 this.pendingWorkflow = pendingWorkflow;
82 public String toString () {
83 String error = "" + statusCode + " " + statusMessage + ": " + errorDetail + (pendingWorkflow ? " [workflow pending]" : "");