异常处理

dev
youhong.ai 2023-07-14 20:41:18 +08:00
parent 31c1ca0202
commit b23aadb572
3 changed files with 217 additions and 229 deletions

View File

@ -16,7 +16,6 @@ import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
@ -166,7 +165,7 @@ public class SignFtService {
try {
try {
tokenUtils.setAlgorithm(Algorithm.HMAC256(secretMap.get("clientSecret")));
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
tokenUtils.setExpiresAt(new Date());

View File

@ -12,7 +12,6 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
@ -68,7 +67,7 @@ public class TokenUtils {
this.secret = secret;
try {
this.algorithm = Algorithm.HMAC256(secret);
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
this.claims = claims;

View File

@ -22,7 +22,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
@ -42,8 +41,7 @@ public class FaDDController {
/**
*
*
* @param workflowId
* id
* @param workflowId id
* @return
*/
@GET
@ -60,8 +58,7 @@ public class FaDDController {
/**
*
*
* @param params
*
* @param params
* @return
*/
@Path("/signature")
@ -80,10 +77,8 @@ public class FaDDController {
/**
*
*
* @param workflowId
* id
* @param requestId
* id
* @param workflowId id
* @param requestId id
* @return
*/
@Path("/signedContract/{languageGroupId}/{requestId}/{workflowId}")
@ -108,10 +103,8 @@ public class FaDDController {
/**
*
*
* @param workflowId
* id
* @param requestId
* id
* @param workflowId id
* @param requestId id
* @return
*/
@Path("/signedContract/own/{languageGroupId}/{requestId}/{workflowId}")
@ -135,7 +128,7 @@ public class FaDDController {
String info = language.get("contractSignedInfo");
return ApiResult.success(info);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
@ -143,8 +136,7 @@ public class FaDDController {
/**
*
*
* @param requestId
* id
* @param requestId id
* @return
*/
@Path("/contract/download/{workflowId}/{requestId}")
@ -158,7 +150,7 @@ public class FaDDController {
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM).type("application/zip")
.header("Content-Disposition", "attachment;filename=contracts.zip").build();
} catch (Exception e) {
toolUtil.writeErrorLog("转换失败," + e.toString());
toolUtil.writeErrorLog("转换失败," + e);
return Response.ok(ApiResult.error("出现错误,错误原因: " + e), MediaType.APPLICATION_JSON).build();
}
}
@ -166,8 +158,7 @@ public class FaDDController {
/**
*
*
* @param workflowId
* id
* @param workflowId id
* @return id
*/
@Path("/getAllVersion/{workflowId}/{markOnly}")
@ -179,7 +170,7 @@ public class FaDDController {
Map<String, Object> allVersion = faDDService.getAllVersion(workflowId, markOnly);
return ApiResult.success(allVersion);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
@ -187,8 +178,7 @@ public class FaDDController {
/**
*
*
* @param requestId
* id
* @param requestId id
* @return
*/
@Path("/isAllSigned/{workflowId}/{requestId}")
@ -236,14 +226,14 @@ public class FaDDController {
byte[] decode = Base64.getDecoder().decode(bizContent.getBytes(StandardCharsets.UTF_8));
String decodeStr = null;
try {
decodeStr = new String(decode, "UTF-8");
} catch (UnsupportedEncodingException e) {
decodeStr = new String(decode, StandardCharsets.UTF_8);
} catch (Exception e) {
e.printStackTrace();
}
String jsonStr = null;
try {
jsonStr = URLDecoder.decode(decodeStr, "UTF-8");
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
e.printStackTrace();
}
JSONObject jsonObject = JSON.parseObject(jsonStr);