title: Apache Camel - What is the best way to handle a 404 error?
body: <p>I am using Apache Camel with Spring Boot and Jetty as embedded server. </p>
  
  <p>I have a RouteBuilder that is defined with the following routes:</p>
  
  <pre><code>    onException(Exception.class)
               .handled(true)
               .process(new ErrorProcessor());
  
      rest("/mysvc/requests/{id}")
              .consumes("application/json")
              .produces("application/json")
              .get()
              .to("direct:processMyRequest");
  
      from("direct:processMyRequest")
              .log("Hello World");
  </code></pre>
  
  <p>When I hit my REST endpoint with a request like <code>GET /mysvc/requests/123</code>, I get a valid response <code>Hello World</code> back.</p>
  
  <p>In the case where I hit a wrong endpoint like <code>GET /mysvc/requests</code> (without providing an id), I simply get a response code <code>404</code> with the following response body:</p>
  
  <pre><code>{
    url: "/mysvc/requests",
    status: "404",
    message: "Not Found",
    servlet: "CamelServlet",
  }
  </code></pre>
  
  <p>I have noticed that there is no exception caught by the <code>onException</code> clause and neither is my <code>ErrorProcessor()</code> called. Why is this the case?</p>
  
  <p>How can I ensure that such errors are caught by the <code>onException</code> clause?</p>