public static Message createErrorMessage (String type, Message input, Throwable problem)
{
if (input == null)
throw new IllegalArgumentException();
Message errorMessage = MessageFactory.getInstance().getMessage(input.getType());
if (errorMessage == null)
throw new IllegalArgumentException("Could not create error message from "+input.getType());
if (modifyMessage(input, errorMessage))
{
errorMessage.getBody().add(Fault.THROWABLE_CONTENT, problem);
try
{
errorMessage.getFault().setCode(new URI(type));
/*
* Is there an exception? If so, add the string as the reason.
*/
if (problem != null)
errorMessage.getFault().setReason(problem.toString());
}
catch (final Exception ex)
{
_logger.debug("Caught exception "+ex+" during message creation!");