This commit is contained in:
tanglong 2026-06-02 11:59:01 +08:00
parent ac18a2cc5c
commit f6dbf915f3
2 changed files with 9 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package com.company.agentfoundation.controller;
import com.company.agentfoundation.security.UnauthorizedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ -12,18 +14,23 @@ import java.util.Map;
@RestControllerAdvice
public class GlobalExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler(UnauthorizedException.class)
public ResponseEntity<Map<String, Object>> unauthorized(UnauthorizedException ex) {
log.warn("request unauthorized: {}", ex.getMessage());
return build(HttpStatus.UNAUTHORIZED, ex.getMessage());
}
@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<Map<String, Object>> badRequest(IllegalArgumentException ex) {
log.warn("request bad: {}", ex.getMessage(), ex);
return build(HttpStatus.BAD_REQUEST, ex.getMessage());
}
@ExceptionHandler(Exception.class)
public ResponseEntity<Map<String, Object>> generic(Exception ex) {
log.error("request failed", ex);
return build(HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
}

View File

@ -1,8 +1,10 @@
package com.company.agentfoundation.integration.wecom;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@JsonIgnoreProperties(ignoreUnknown = true)
@JacksonXmlRootElement(localName = "xml")
public class WecomIncomingMessage {
@JacksonXmlProperty(localName = "ToUserName")