You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added a new class 'ExceptionHand' in the 'Exception' file in the master branch to avoid the complexity of displaying errors when retrieving or deleting data that does not exist in the database by showing a clear and simple message.
code :
package com.example.easynotes.exception;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ControllerAdvice
public class ExceptionHand {
@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<String> handleMyCustomException(ResourceNotFoundException ex) {
// Handle the exception and return an appropriate response
return new ResponseEntity<>( ex.getMessage(), HttpStatus.NOT_FOUND);
}
}
Error message before the addition of the class:
L'erreur qui s'affiche après l'ajout de la class ExceptionHand
The text was updated successfully, but these errors were encountered:
jguirimm
changed the title
Ajout de la class "ExceptionHand" pour la gestion d'exceptions
Added the 'ExceptionHand' class for exception handling
Jan 13, 2024
jguirimm
changed the title
Added the 'ExceptionHand' class for exception handling
Feature : Added the 'ExceptionHand' class for exception handling
Jan 13, 2024
Added a new class 'ExceptionHand' in the 'Exception' file in the master branch to avoid the complexity of displaying errors when retrieving or deleting data that does not exist in the database by showing a clear and simple message.
code :
package com.example.easynotes.exception;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ControllerAdvice
public class ExceptionHand {
}
Error message before the addition of the class:
L'erreur qui s'affiche après l'ajout de la class ExceptionHand
The text was updated successfully, but these errors were encountered: