You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.0 KiB
28 lines
1.0 KiB
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;
|
|
}
|
|
}
|