| 1234567891011121314151617181920212223242526 |
- package com.webflux.launchadmin.global;
- import com.webflux.launchcommon.returnObj.RW;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.http.HttpStatus;
- import org.springframework.web.bind.annotation.ExceptionHandler;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.bind.annotation.ResponseStatus;
- import org.springframework.web.bind.annotation.RestControllerAdvice;
- import reactor.core.publisher.Mono;
- @RestControllerAdvice
- @Slf4j
- public class GlobalExceptionHandler {
- @ResponseBody
- @ResponseStatus(HttpStatus.BAD_REQUEST)
- @ExceptionHandler(Exception.class)
- public Mono<RW<Object>> handleException(Exception e) {
- log.error(e.toString());
- return RW.fail("500",e.getMessage(),Mono.just(e.getMessage()));
- }
- }
|