title: How to catch custom java8 exception from react?
body: <p>Following code generates exception as UserAlreadyExist.</p>
  <pre><code>Optional&lt;User&gt; userCheck = userRepository.findByUsername(createRequest.getUsername());
      if(StringUtils.hasText(userCheck.get().getUsername())){
          String errorMessage = &quot;User already exist: &quot;+ userCheck.get().getUsername();
          throw new UserAlreadyExistException(errorMessage);
      }
  </code></pre>
  <p>When i try to get error message from my react app with these codes i only get Internal server error message. My header contains header token and application/JSON header.</p>
  <pre><code>export const createUserService = (data) =&gt; {
  return new Promise(((resolve, reject) =&gt; {
      axios.post(USERS_BASE, data, getHeaderWithToken())
          .then(function (response) {
              resolve(response);
          })
          .catch(error=&gt;{
          console.log(error)//returns &quot;Internal Server Error&quot; message
          console.log(error.response) // returns object with empty message field and other parameters.
              reject(error)
      })
  }));
  </code></pre>
  <p>};</p>
  <p>How can i get the error message i sent like</p>
  <pre><code>String errorMessage = &quot;User already exist: &quot;+ userCheck.get().getUsername();
          throw new UserAlreadyExistException(errorMessage);
      
  </code></pre>
  <p>this is my UserAlreadyExistException class btw.</p>
  <pre><code>public class UserAlreadyExistException extends RuntimeException {
  public UserAlreadyExistException(String message) {
      super(message);
      
  }}
  </code></pre>