The error message template is constructed such that a property submitted with the request controls the the form of the error response. Perhaps the simplest way to understand how this works is to look at the error template in detail. Here it is:
#if ($las_request.getProperty("las", "output_type") == 'json')
$las_response.brief().toJSON()
#elseif ($las_request.getProperty("las", "output_type") == 'xml')
$las_response.toString()
#else
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- LAS SERVER OK -->
<head><title>LAS Output</title></head>
<body bgcolor="white">
<h3>$las_response.getResult("las_message")</h3>
<hr>
<a href="ProductServer.do?xml=$las_request.toEncodedURLString()">The URL of this product.</a>
<hr>
#if ( $debug=="trace" || $debug=="debug" )
#if ( $las_response.getResult("debug") != "" )
<a href="$las_response.getResult("debug")">More details about this error.</a>
#end
<hr>
<pre>
$las_response.getResult("exception_message")
</pre>
#else
#if ( $las_response.getResult("debug") != "" )
<a href="$las_response.getResult("debug")">More details about this error.</a>
#end
#end
</body>
</html>
#end
The important part of the template for this discussion is the three way IF block of the form:
#if ($las_request.getProperty("las", "output_type") == 'json')
[...]
#elseif ($las_request.getProperty("las", "output_type") == 'xml')
[...]
#else
[...]
#end
In the first instance if the request includes an "las" property with the value "json" the template will be processed such that it produces a JSON object that contains a brief user friendly error message (the contents of which can be configured in the case of the Ferret Backend Service).
If you are developing a client and would prefer to process the error response as an XML document you can get the response in that form by including an "las" property with the value "xml".
If the "las" property is not set or if it contains a value other than "json" or "xml" then the template is processed to produce an HTML document. This the default situation for LAS requests. The HTML document is very brief by default, but if the request or the LAS is running in debug mode then all of the error information that is available is included in the document.