title: Spring boot handling exception - Failed to write HTTP message
body: <p>i want to handle the error for the following controller method  </p>
  
  <pre><code>@GetMapping(value= "search", params = {"id", "!name"})
      public ResponseEntity&lt;?&gt; getMovieById(@RequestParam(name = "id") short id) {
          Movie movie = this.movieService.getMovieById(id);
          if(null == movie) {
              throw new MovieNotFoundException("Unable to find moviee with id: " + id);
          }
          return ResponseEntity.ok(movie);
      }
  </code></pre>
  
  <p>so if the id in the link nit found i'm throwing <code>MovieNotFoundException</code>.<br>
  but spring throw the following error:  </p>
  
  <pre><code>Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Unable to find com.movies.mmdbapi.model.Movie with id 6; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unable to find com.movies.mmdbapi.model.Movie with id 6
  </code></pre>