//////////////////////////////////////////////////////////////////////////////// // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// package mx.messaging.events { import flash.events.Event; import mx.messaging.messages.ErrorMessage; /** * The MessageFaultEvent class is used to propagate fault messages within the messaging system. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ public class MessageFaultEvent extends Event { //-------------------------------------------------------------------------- // // Static Constants // //-------------------------------------------------------------------------- /** * The FAULT event type; dispatched for a message fault. *

The value of this constant is "fault".

* *

The properties of the event object have the following values:

* * * * * * * * * * * *
PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
faultCodeProvides destination-specific * details of the failure.
faultDetailProvides access to the * destination-specific reason for the failure.
faultStringProvides access to the underlying * reason for the failure if the channel did not raise the failure itself.
messageThe ErrorMessage for this event.
rootCause Provides access to the underlying reason * for the failure, if one exists.
targetThe Object that dispatched the event; * it is not always the Object listening for the event. * Use the currentTarget property to always access the * Object listening for the event.
* @eventType fault * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ public static const FAULT:String = "fault"; //-------------------------------------------------------------------------- // // Static Methods // //-------------------------------------------------------------------------- /** * Utility method to create a new MessageFaultEvent that doesn't bubble and * is not cancelable. * * @param message The ErrorMessage associated with the fault. * * @return New MessageFaultEvent. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ public static function createEvent(msg:ErrorMessage):MessageFaultEvent { return new MessageFaultEvent(MessageFaultEvent.FAULT, false, false, msg); } //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructs an instance of a fault message event for the specified message * and fault information. * * @param type The type for the MessageAckEvent. * * @param bubbles Specifies whether the event can bubble up the display * list hierarchy. * * @param cancelable Indicates whether the behavior associated with the * event can be prevented. * * @param message The ErrorMessage associated with the fault. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ public function MessageFaultEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, message:ErrorMessage = null) { super(type, bubbles, cancelable); this.message = message; } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- /** * The ErrorMessage for this event. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ public var message:ErrorMessage; //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // faultCode //---------------------------------- /** * Provides access to the destination specific failure code. * For more specific details see faultString and * faultDetails properties. * *

The format of the fault codes are provided by the remote destination, * but, will typically have the following form: host.operation.error * For example, "Server.Connect.Failed"

* * @see #faultString * @see #faultDetail * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ public function get faultCode():String { return message.faultCode; } //---------------------------------- // faultDetail //---------------------------------- /** * Provides destination specific details of the failure. * *

Typically fault details are a stack trace of an exception thrown at * the remote destination.

* * @see #faultString * @see #faultCode * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ public function get faultDetail():String { return message.faultDetail; } //---------------------------------- // faultString //---------------------------------- /** * Provides access to the destination specific reason for the failure. * * @see #faultCode * @see #faultDetail * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ public function get faultString():String { return message.faultString; } //---------------------------------- // rootCause //---------------------------------- /** * Provides access to the root cause of the failure, if one exists. * * In the case of custom exceptions thrown by a destination, the root cause * represents the top level failure that is merely transported by the * ErrorMessage. * * @see MessageFaultEvent#rootCause * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ public function get rootCause():Object { return message.rootCause; } //-------------------------------------------------------------------------- // // Overridden Methods // //-------------------------------------------------------------------------- /** * Clones the MessageFaultEvent. * * @return Copy of this MessageFaultEvent. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ override public function clone():Event { return new MessageFaultEvent(type, bubbles, cancelable, message); } /** * Returns a string representation of the MessageFaultEvent. * * @return String representation of the MessageFaultEvent. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion BlazeDS 4 * @productversion LCDS 3 */ override public function toString():String { return formatToString("MessageFaultEvent", "faultCode", "faultDetail", "faultString", "rootCause", "type", "bubbles", "cancelable", "eventPhase"); } } }