|
16 | 16 | // under the License. |
17 | 17 | package org.apache.cloudstack.api.command.admin.host; |
18 | 18 |
|
| 19 | +import com.cloud.exception.AgentUnavailableException; |
| 20 | +import com.cloud.exception.InvalidParameterValueException; |
| 21 | +import com.cloud.utils.exception.CloudRuntimeException; |
19 | 22 | import org.apache.log4j.Logger; |
20 | 23 |
|
21 | 24 | import org.apache.cloudstack.api.APICommand; |
@@ -100,17 +103,18 @@ public Long getInstanceId() { |
100 | 103 | @Override |
101 | 104 | public void execute() { |
102 | 105 | try { |
103 | | - Host result = _resourceService.reconnectHost(this); |
104 | | - if (result != null) { |
105 | | - HostResponse response = _responseGenerator.createHostResponse(result); |
106 | | - response.setResponseName(getCommandName()); |
107 | | - this.setResponseObject(response); |
108 | | - } else { |
109 | | - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reconnect host"); |
110 | | - } |
111 | | - } catch (Exception ex) { |
112 | | - s_logger.warn("Exception: ", ex); |
113 | | - throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); |
| 106 | + Host result =_resourceService.reconnectHost(this); |
| 107 | + HostResponse response = _responseGenerator.createHostResponse(result); |
| 108 | + response.setResponseName(getCommandName()); |
| 109 | + this.setResponseObject(response); |
| 110 | + }catch (InvalidParameterValueException e) { |
| 111 | + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, e.getMessage()); |
| 112 | + } |
| 113 | + catch (CloudRuntimeException e) { |
| 114 | + s_logger.warn("Exception: ", e); |
| 115 | + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); |
| 116 | + }catch (AgentUnavailableException e) { |
| 117 | + throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, e.getMessage()); |
114 | 118 | } |
115 | 119 | } |
116 | 120 | } |
0 commit comments