Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created April 28, 2020 02:17
Show Gist options
  • Save CheolhoJeon/77da014f24812ba1aa7b2c1fa6fbb4a9 to your computer and use it in GitHub Desktop.
Save CheolhoJeon/77da014f24812ba1aa7b2c1fa6fbb4a9 to your computer and use it in GitHub Desktop.
package controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import spring.MemberNotFoundException;
@RestControllerAdvice("controller")
public class ApiExceptionAdvice {
@ExceptionHandler(MemberNotFoundException.class)
public ResponseEntity<Object> handleNoData() {
return ResponseEntity
.status(HttpStatus.NOT_FOUND)
.body(new ErrorResponse("no member"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment