Commit 53653216 authored by liaozan's avatar liaozan 🏀

Avoid evaluate variable everytime

parent f1a45790
......@@ -12,12 +12,18 @@ import org.springframework.core.Ordered;
*/
public class DefaultExceptionTranslator implements ExceptionTranslator {
private final boolean isProduction;
public DefaultExceptionTranslator() {
this.isProduction = EnvUtils.isProduction();
}
@Override
public ResponseDTO<String> translate(Throwable throwable, int code, int action, String message) {
if (throwable instanceof BaseException) {
return ResponseDTO.error((BaseException) throwable);
}
if (EnvUtils.isProduction() || StringUtils.isBlank(message)) {
if (isProduction || StringUtils.isBlank(message)) {
return ResponseDTO.error("系统错误", code);
}
return ResponseDTO.error(message, code, action);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment