org.codehaus.xfire.fault
Class XFireFault

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.codehaus.xfire.fault.XFireFault
All Implemented Interfaces:
java.io.Serializable

public class XFireFault
extends java.lang.Exception

In XFire, applications throw their own declared exceptions which are then turned into faults. The XFireFault class wraps these exceptions extracting out the details for the fault message.

If the developer wishes to generate their own custom fault messages, they can either override XFireFault to provide the FaultHandlers with the necessary information or write a new FaultHandler.

TODO Add i18n support

Since:
Feb 14, 2004
Author:
Dan Diephouse
See Also:
Serialized Form

Field Summary
static java.lang.String DATA_ENCODING_UNKNOWN
           
static java.lang.String MUST_UNDERSTAND
           
static java.lang.String RECEIVER
           A SOAP 1.2 only fault code.
static java.lang.String SENDER
          "The message was incorrectly formed or did not contain the appropriate information in order to succeed." -- SOAP 1.2 Spec
static java.lang.String VERSION_MISMATCH
          Fault codes.
 
Constructor Summary
protected XFireFault()
           
  XFireFault(java.lang.String message, java.lang.String code)
          Create an exception wih the specified fault message and faultCode.
  XFireFault(java.lang.String message, java.lang.Throwable throwable, java.lang.String code)
          Create a fault.
  XFireFault(java.lang.Throwable throwable)
          Create a fault for the specified exception.
  XFireFault(java.lang.Throwable throwable, java.lang.String code)
          Create a fault with the specified faultCode.
 
Method Summary
 void addNamespace(java.lang.String prefix, java.lang.String ns)
           
static XFireFault createFault(java.lang.Throwable throwable)
           
 java.lang.String getCode()
           
 org.w3c.dom.Node getDetail()
           
 java.lang.String getFaultCode()
           
 java.lang.String getMessage()
           
 java.util.Map getNamespaces()
          User defined namespaces which will be written out on the resultant SOAP Fault (for use easy with SubCodes and Detail) elements.
 java.lang.String getReason()
           
 java.lang.String getRole()
           
 java.lang.String getSubCode()
          Returns the SubCode for the Fault Code.
 boolean hasDetails()
           
 void setDetail(org.w3c.dom.Node details)
           
 void setFaultCode(java.lang.String faultCode)
           
 void setMessage(java.lang.String message)
           
 void setRole(java.lang.String actor)
          Sets the fault actor.
 void setSubCode(java.lang.String subCode)
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION_MISMATCH

public static final java.lang.String VERSION_MISMATCH
Fault codes.

See Also:
Constant Field Values

MUST_UNDERSTAND

public static final java.lang.String MUST_UNDERSTAND
See Also:
Constant Field Values

DATA_ENCODING_UNKNOWN

public static final java.lang.String DATA_ENCODING_UNKNOWN
See Also:
Constant Field Values

SENDER

public static final java.lang.String SENDER
"The message was incorrectly formed or did not contain the appropriate information in order to succeed." -- SOAP 1.2 Spec

See Also:
Constant Field Values

RECEIVER

public static final java.lang.String RECEIVER

A SOAP 1.2 only fault code.

"The message could not be processed for reasons attributable to the processing of the message rather than to the contents of the message itself." -- SOAP 1.2 Spec

If this message is used in a SOAP 1.1 Fault it will most likely (depending on the FaultHandler) be mapped to "Sender" instead.

See Also:
Constant Field Values
Constructor Detail

XFireFault

public XFireFault(java.lang.String message,
                  java.lang.Throwable throwable,
                  java.lang.String code)
Create a fault.

Parameters:
throwable - The exception which caused this fault.
code - The fault code. See XFireFault's static fields.

XFireFault

public XFireFault(java.lang.Throwable throwable)
Create a fault for the specified exception. The faultCode is set to RECEIVER.

Parameters:
throwable -

XFireFault

public XFireFault(java.lang.Throwable throwable,
                  java.lang.String code)
Create a fault with the specified faultCode. The exception message is used for the fault message.

Parameters:
throwable - The exception that caused this fault.
code - The fault code. See XFireFault's static fields.

XFireFault

public XFireFault(java.lang.String message,
                  java.lang.String code)
Create an exception wih the specified fault message and faultCode.

Parameters:
message - The fault message.
code - The fault code. See XFireFault's static fields.

XFireFault

protected XFireFault()
Method Detail

createFault

public static XFireFault createFault(java.lang.Throwable throwable)

getCode

public java.lang.String getCode()
Returns:

getReason

public java.lang.String getReason()

getSubCode

public java.lang.String getSubCode()
Returns the SubCode for the Fault Code.

Returns:
The SubCode element as detailed by the SOAP 1.2 spec.

getDetail

public org.w3c.dom.Node getDetail()

setDetail

public void setDetail(org.w3c.dom.Node details)

setSubCode

public void setSubCode(java.lang.String subCode)

getFaultCode

public java.lang.String getFaultCode()

setFaultCode

public void setFaultCode(java.lang.String faultCode)

getNamespaces

public java.util.Map getNamespaces()
User defined namespaces which will be written out on the resultant SOAP Fault (for use easy with SubCodes and Detail) elements.

Returns:

addNamespace

public void addNamespace(java.lang.String prefix,
                         java.lang.String ns)

hasDetails

public boolean hasDetails()
Returns:

getMessage

public java.lang.String getMessage()
Overrides:
getMessage in class java.lang.Throwable
Returns:
Returns the message.

setMessage

public void setMessage(java.lang.String message)
Parameters:
message - The message to set.

getRole

public java.lang.String getRole()
Returns:
Returns the fault actor.

setRole

public void setRole(java.lang.String actor)
Sets the fault actor.

Parameters:
actor -


Copyright © 2004-2005 Codehaus. All Rights Reserved.