Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created April 28, 2020 02:17
Show Gist options
  • Save CheolhoJeon/b9013f49bf9889d92674bad58f2f32d0 to your computer and use it in GitHub Desktop.
Save CheolhoJeon/b9013f49bf9889d92674bad58f2f32d0 to your computer and use it in GitHub Desktop.
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