Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature : Added the 'ExceptionHand' class for exception handling #14

Open
jguirimm opened this issue Jan 12, 2024 · 0 comments
Open

Feature : Added the 'ExceptionHand' class for exception handling #14

jguirimm opened this issue Jan 12, 2024 · 0 comments

Comments

@jguirimm
Copy link

jguirimm commented Jan 12, 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 {

@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:
Erreur Exception
L'erreur qui s'affiche après l'ajout de la class ExceptionHand
Exception_solu
l'arborecsence

@jguirimm 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 jguirimm changed the title Added the 'ExceptionHand' class for exception handling Feature : Added the 'ExceptionHand' class for exception handling Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant