title: How to catch 400 Bad request in java
body: <p>I have to catch the 400 Bad request and perform operation accordingly.</p>
  <p>I have one solution and it is working as expected:</p>
  <pre><code>
  try {
  
  //some rest api code
  } catch (HttpStatusCodeException e) {
              if (e.getStatusCode() == HttpStatus.BAD_REQUEST) {
                  // Handle Bad Request and perform operation according to that..
  
              }
  }
  
  </code></pre>
  <p>But I don't know if it is good approach to catch HttpStatusCodeException and then check on status code or not.</p>
  <p>Can someone suggest another way to handle 400 Bad request?</p>