Issue
I have this exception message:
public CityDto getCityByName(String name) throws DataNotFoundException {
CityEntity cityEntity = cityRepository.findByName(name);
if (cityEntity == null){
throw new DataNotFoundException("city with name " + '"' + name + '"' + " not found!");
}else
return CityMapper.INSTANCE.toCityDto(cityEntity);
}
and this how Postman show me this message:
{
"status": "NOT_FOUND",
"message": "Entity not found",
"errors": [
"city with name \"Toronto\" not found!"
]
}
As u can see, city name Toronto for some reason have backslash. How to remove it?
Solution
do this throw new DataNotFoundException("city with name '" + name + "' not found!")
Answered By - Artur May
Answer Checked By - Katrina (JavaFixing Volunteer)