Skip to content

Instantly share code, notes, and snippets.

@amiremohamadi
Created August 7, 2019 13:26
Show Gist options
  • Select an option

  • Save amiremohamadi/282cd2d32734f4709b79e6823f2e1a67 to your computer and use it in GitHub Desktop.

Select an option

Save amiremohamadi/282cd2d32734f4709b79e6823f2e1a67 to your computer and use it in GitHub Desktop.
YO
package com.rahnema.college.team3.auctionak.controllers;
import org.omg.CORBA.Object;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.request.WebRequest;
@ControllerAdvice
public class ExceptionController {
@ExceptionHandler({RuntimeException.class})
public ResponseEntity<?> handleRuntimeException(Exception ex, WebRequest req) {
return new ResponseEntity<>(
ex.getMessage(), new HttpHeaders(), HttpStatus.FORBIDDEN
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment