title: Java Exception and HTTP 500 Error
body: <p>Is there any relevance with Java Exceptions at server side and <code>500</code> error code of <code>http</code> which is <code>Internal Server Error</code>. It happens because of <code>unhandled exceptions</code> in <code>catch</code> block or it could be because of of <code>unchecked</code> exceptions which is raised over <code>runtime</code></p>
  
  <p>How could I arrive to the conclusion, for me,- it is <code>Apache Camel</code> project which has <code>spring-boot-starter-parent</code> and has <code>Spring Quartz</code> Configured within. Basically <code>REST</code> calls through <code>OAuth 1.0</code> authentication probagates.</p>
  
  <p>I am testing my application from <code>Swagger</code>. I am not able conclude that,</p>
  
  <ol>
  <li><code>OAuth 1.0</code> Authentication is succeeded or not</li>
  <li>Error Handler Routines couldn't capture the specific,- <code>error code</code> in the project, as it is <code>unhandled</code> and <code>runtime exception</code> basically</li>
  </ol>
  
  <p>Swagger gives following response with 500 error code.</p>
  
  <pre><code>"&lt;Error&gt;&lt;Message&gt;An error has occurred.&lt;/Message&gt;&lt;ExceptionMessage&gt;Object reference not set to an instance of an object.&lt;/ExceptionMessage&gt;&lt;ExceptionType&gt;System.NullReferenceException&lt;/ExceptionType&gt;&lt;StackTrace&gt;   at API.ExecutionTimeFilterAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)&amp;#xD;\n   at System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)&amp;#xD;\n--- End of stack trace from previous location where exception was thrown ---&amp;#xD;\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#xD;\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&amp;#xD;\n   at System.Web.Http.Filters.ActionFilterAttribute.&amp;lt;CallOnActionExecutedAsync&amp;gt;d__5.MoveNext()&amp;#xD;\n--- End of stack trace from previous location where exception was thrown ---&amp;#xD;\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#xD;\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&amp;#xD;\n   at System.Web.Http.Filters.ActionFilterAttribute.&amp;lt;ExecuteActionFilterAsyncCore&amp;gt;d__0.MoveNext()&amp;#xD;\n--- End of stack trace from previous location where exception was thrown ---&amp;#xD;\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#xD;\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&amp;#xD;\n   at System.Web.Http.Controllers.ActionFilterResult.&amp;lt;ExecuteAsync&amp;gt;d__2.MoveNext()&amp;#xD;\n--- End of stack trace from previous location where exception was thrown ---&amp;#xD;\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#xD;\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&amp;#xD;\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.&amp;lt;ExecuteAuthorizationFilterAsyncCore&amp;gt;d__2.MoveNext()&amp;#xD;\n--- End of stack trace from previous location where exception was thrown ---&amp;#xD;\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#xD;\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&amp;#xD;\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.&amp;lt;SendAsync&amp;gt;d__1.MoveNext()&lt;/StackTrace&gt;&lt;/Error&gt;"
  </code></pre>
  
  <p>Even with wrong <code>secret key</code>, <code>consumer key</code>, it is the same scenario.</p>
  
  <p>I presume that keys are improper for both the scenario.</p>
  
  <p>However I would like to know,</p>
  
  <blockquote>
    <p>is 500 error code is common for unhandled exceptions &amp; unchecked
    runtime exceptions or there we will be 400 series</p>
  </blockquote>
  
  <p>How could I judge the testing scenario if http (500) error code is arisen other than custom java error code which handled in code and been responded back as part of response string for a <code>REST</code> calls.</p>