Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
@jguirimm

Description

@jguirimm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp