-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 'hotfix-2.1.1'
# Conflicts: # choerodon-gitlab4j-api/pom.xml # choerodon-starter-asgard/pom.xml # choerodon-starter-core/pom.xml # choerodon-starter-fragment/pom.xml # choerodon-starter-limit/pom.xml # choerodon-starter-nacos-client/pom.xml # choerodon-starter-only-office/pom.xml # choerodon-tool-liquibase/pom.xml # pom.xml
- Loading branch information
Showing
10 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
choerodon-starter-core/src/main/java/io/choerodon/core/utils/FeignFallbackUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.choerodon.core.utils; | ||
|
||
import java.lang.reflect.InvocationHandler; | ||
import java.lang.reflect.Proxy; | ||
import java.util.Arrays; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.util.Assert; | ||
|
||
/** | ||
* Copyright (c) 2022. Hand Enterprise Solution Company. All right reserved. | ||
* | ||
* @author [email protected] | ||
* @since 2022/7/13 | ||
*/ | ||
public class FeignFallbackUtil { | ||
|
||
private FeignFallbackUtil() { | ||
} | ||
|
||
public static <T> T get(Throwable cause, Class<T> targetClass) { | ||
Assert.notNull(targetClass, "feign target class could not be null!"); | ||
Logger logger = LoggerFactory.getLogger(targetClass); | ||
InvocationHandler invocationHandler = (proxy, method, args) -> { | ||
logger.error("error when call {}.{} by params{}", method.getDeclaringClass().getSimpleName(), | ||
method.getName(), JSON.toJSONString(args)); | ||
if (cause != null) { | ||
logger.error(cause.getMessage(), cause); | ||
} | ||
return ResponseEntity.badRequest().contentType(MediaType.APPLICATION_JSON).body("请联系运维人员"); | ||
}; | ||
return (T) Proxy.newProxyInstance(targetClass.getClassLoader(), new Class[]{targetClass}, invocationHandler); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters