修改调用外部程序异常的错误提示信息

This commit is contained in:
DuanDongmei
2018-11-20 13:04:37 +08:00
parent bec11857d0
commit ffd9c2ec44
12 changed files with 58 additions and 27 deletions

View File

@@ -206,7 +206,7 @@ public class ConfigServiceUtil {
* @return
* @throws Exception
*/
public static ToMaatResult postFileCfg(String params,File file,String fileDesc) throws MaatConvertException{
public static ToMaatResult postFileCfg(String params,File file,String fileDesc) throws Exception{
String result = null;
ToMaatResult bean = null;
String url = Constants.SERVICE_URL+Constants.FILE_UPLOAD_CFG;
@@ -217,13 +217,18 @@ public class ConfigServiceUtil {
FileDataBodyPart bodyPart=new FileDataBodyPart("file",file);
formDataMultiPart.bodyPart(bodyPart);
Builder header = wt.request(MediaType.APPLICATION_JSON).header("File-Desc",fileDesc);
Response response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
if( response.getStatus() == 200){
Response response=null;
try {
response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
} catch (Exception e) {
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
if(response != null && response.getStatus() == 200){
result= response.readEntity(String.class);
JSONObject resObject = JSONObject.fromObject(result);
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
}else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
return bean;