0

注釈@ExceptionHandlerを使用するときに例外オブジェクトに入る方法はありますか?例外ハンドラメソッド内のエラーオブジェクトへのアクセス

これは私のコードです:

@ExceptionHandler(DataInputException.class) 
    public ResponseEntity handleException(){ 
     return ResponseEntity 
        .status(HttpStatus.BAD_REQUEST) 
        .body("Entity contains null or forbidden values"); 
    } 

私はperticularフィールドに関するカスタマイズされた情報を格納するためのメッセージを返したしたいと思います。 (そのため、私はエラーオブジェクトが必要です)。

答えて

3

例外でパス

@ExceptionHandler(DataInputException.class) 
public ResponseEntity handleException(DataInputException exception) { 
関連する問題