吴学文
2019-04-25 2a2bc2abf283784151fe1c15047ff65d41ce5583
WebService/src/main/java/com/java110/web/controller/CallComponentController.java
@@ -16,6 +16,7 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -62,7 +63,16 @@
            headers.add("code",e.getResult().getCode());
            responseEntity = new ResponseEntity<>(e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
        }catch (Exception e){
            responseEntity = new ResponseEntity<>(e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
            String msg = "";
            if (e instanceof InvocationTargetException) {
                Throwable targetEx =((InvocationTargetException)e).getTargetException();
                if (targetEx != null) {
                    msg = targetEx.getMessage();
                }
            } else {
                msg = e.getMessage();
            }
            responseEntity = new ResponseEntity<>(msg,HttpStatus.INTERNAL_SERVER_ERROR);
        }finally {
            logger.debug("组件调用返回信息为{}",responseEntity);
            return responseEntity;