package com.dreamworks.boditech.utils; import com.dreamworks.boditech.controller.entity.ApiResponse; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; @ControllerAdvice public class AppExceptionHandler { @ExceptionHandler(value = AppRuntimeException.class) @ResponseBody public ApiResponse handleAppRuntimeException(AppRuntimeException e) { ApiResponse response = new ApiResponse(); response.success = false; response.message = e.getMessage(); response.data = null; response.code = e.getCode(); return response; } @ExceptionHandler(value = RuntimeException.class) @ResponseBody public ApiResponse handleRuntimeException(RuntimeException e ) { ApiResponse response = new ApiResponse(); response.success = false; response.message = e.getMessage(); response.data = null; return response; } }