title: How to avoid exception stack in response body
body: <p>I am currently using Spring MVC 3.0.6. My expectation is whenever any exception is thrown at Spring level (i.e.- before reaching request to my controller), no exception stack will be returned as response body. When expected result is HTML then control goes to an error page containing custom error message. In this scenario outcome is matched with my expectation.</p>
  
  <p>But I am facing problem while expected result is JSON. In this scenario I am getting exception stack as JSON format.</p>
  
  <p>e.g.-</p>
  
  <p>Requested URL - /MyApp/secure/employee/name.json?employee=815009&amp;.........</p>
  
  <p>Let say by URL tampering one put employee= 815003333333333333333333333333333333333333333333333333333333333333333333333333333333339 (means huge payload).</p>
  
  <p>Now I am getting response like –</p>
  
  <p>{ "exception":{"value":"8150………..9",
  "errorCode":"typeMismatch","requiredType":"long","propertyName":null,"propertyChangeEvent":null,"message":"Failed to convert value of type 'java.lang.String' to required type 'long'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value \"8150…………9\" from type 'java.lang.String' to type 'long'; nested exception is java.lang.NumberFormatException: For input string: \"8150…………………..9\"","rootCause":{"cause":null,"message":"For input string: \"8150………………………9\"","localizedMessage":"For input string: \"8150…………..9\"","stackTrace":[{…………………..}]}}</p>
  
  <p>My expected response will be like –</p>
  
  <p>{"value":["Some custom error message"],"success":false}</p>
  
  <p><strong>Note : In my controller I expect employee as long (data type) in @RequestParam.</strong></p>
  
  <p>My concern is, as exception stack contains details about library from which exception is propagated might make my application vulnerable from security perspective. </p>
  
  <p>Is there any way to return custom message instead of exception stack?</p>