i try to display simple error massage for the unavailable resource of my service model by extending my class with RuntimeException but didn't display
TodoService Implementation
@Override
public String retrieveTodoStatusById(Long id) {
Optional<String> optionalTodo = Optional.ofNullable(todoRepository.findStatusById(id));
System.out.println("OptionalTodo " +optionalTodo );
String status = optionalTodo.orElseThrow(TodoNotFoundException::new);
return status;
}
TodoNotFoundException
package mang.io.todosrestapi.exceptionhandler;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "Todo not available")
public class TodoNotFoundException extends RuntimeException{
public TodoNotFoundException(){
}
public TodoNotFoundException(String message){
super(message);
}
}
default error with no message is display
Every time i run the exception error message is not display How can display the error message?