Commit e9cd3989 by chamberone

fix: add logs

1 parent f6cdd0ef
package com.dituhui.pea.gateway.handler; package com.dituhui.pea.gateway.handler;
import com.dituhui.pea.enums.StatusCodeEnum; import java.util.Arrays;
import com.dituhui.pea.exception.BusinessException;
import com.dituhui.pea.gateway.config.AuthFilter;
import com.dituhui.pea.pojo.WebResult;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler; import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
...@@ -20,6 +11,15 @@ import org.springframework.http.server.reactive.ServerHttpResponse; ...@@ -20,6 +11,15 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.handler.ResponseStatusExceptionHandler; import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.exception.BusinessException;
import com.dituhui.pea.pojo.WebResult;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
/** /**
...@@ -53,7 +53,8 @@ public class GlobalExceptionHandler implements ErrorWebExceptionHandler { ...@@ -53,7 +53,8 @@ public class GlobalExceptionHandler implements ErrorWebExceptionHandler {
StatusCodeEnum codeEnum = ((BusinessException) ex).codeEnum; StatusCodeEnum codeEnum = ((BusinessException) ex).codeEnum;
return bufferFactory.wrap(objectMapper.writeValueAsBytes(WebResult.failed(codeEnum))); return bufferFactory.wrap(objectMapper.writeValueAsBytes(WebResult.failed(codeEnum)));
} else { } else {
log.error("{} 访问网关异常:{} {}", exchange.getRequest().getPath(), ex, ex.getMessage()); log.error("{} 访问网关异常:{} {}", exchange.getRequest().getPath(), Arrays.toString(ex.getStackTrace()),
ex.getMessage());
return bufferFactory.wrap( return bufferFactory.wrap(
objectMapper.writeValueAsBytes(WebResult.failed(StatusCodeEnum.SYSTEM_UNKNOWN_ERROR))); objectMapper.writeValueAsBytes(WebResult.failed(StatusCodeEnum.SYSTEM_UNKNOWN_ERROR)));
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!