|
22 | 22 | import org.apache.hadoop.ozone.OmUtils; |
23 | 23 | import org.apache.hadoop.ozone.om.OzoneManager; |
24 | 24 | import org.apache.hadoop.ozone.om.exceptions.NotLeaderException; |
| 25 | +import org.apache.hadoop.ozone.om.exceptions.OMException; |
25 | 26 | import org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolPB; |
26 | 27 | import org.apache.hadoop.ozone.om.ratis.OzoneManagerDoubleBuffer; |
27 | 28 | import org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer; |
|
34 | 35 |
|
35 | 36 | import com.google.protobuf.RpcController; |
36 | 37 | import com.google.protobuf.ServiceException; |
| 38 | +import org.apache.hadoop.util.StringUtils; |
37 | 39 | import org.apache.ratis.protocol.RaftPeerId; |
38 | 40 | import org.apache.ratis.util.ExitUtils; |
39 | 41 | import org.slf4j.Logger; |
@@ -151,12 +153,21 @@ private OMResponse createErrorResponse( |
151 | 153 | OzoneManagerRatisUtils.exceptionToResponseStatus(exception)) |
152 | 154 | .setCmdType(cmdType) |
153 | 155 | .setSuccess(false); |
154 | | - if (exception.getMessage() != null) { |
155 | | - omResponse.setMessage(exception.getMessage()); |
| 156 | + String errorMsg = exceptionErrorMessage(exception); |
| 157 | + if (errorMsg != null) { |
| 158 | + omResponse.setMessage(errorMsg); |
156 | 159 | } |
157 | 160 | return omResponse.build(); |
158 | 161 | } |
159 | 162 |
|
| 163 | + private String exceptionErrorMessage(IOException ex) { |
| 164 | + if (ex instanceof OMException) { |
| 165 | + return ex.getMessage(); |
| 166 | + } else { |
| 167 | + return StringUtils.stringifyException(ex); |
| 168 | + } |
| 169 | + } |
| 170 | + |
160 | 171 | /** |
161 | 172 | * Submits request to OM's Ratis server. |
162 | 173 | */ |
|
0 commit comments