Skip to content

Commit

Permalink
adding option for adding a fault code to a failed operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultz committed Mar 9, 2011
1 parent f62fd7e commit b61b935
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/operations/FaultOperationEvent.as
Expand Up @@ -13,20 +13,21 @@ package operations
/**
* An event type for when an operation has errored or faulted during execution.
*/
public static const FAULT:String = "fault";
public static const FAULT:String = "fault";

/**
* Constructor.
*
* @param summary A simple description of the fault.
* @param detail A detailed description of the fault.
*/
public function FaultOperationEvent(summary:String, detail:String = "")
public function FaultOperationEvent(summary:String, detail:String = "", code:String = "")
{
super(FAULT);

_summary = summary == null ? "" : summary;
_detail = detail == null ? "" : detail;
_code = code == null ? "" : code;
}

/**
Expand Down Expand Up @@ -54,5 +55,14 @@ package operations
{
return _detail;
}

private var _code:String;
/**
* A specific code given to the fault.
*/
public function get code():String
{
return _code;
}
}
}
9 changes: 9 additions & 0 deletions src/operations/FileReferenceUploadOperation.as
Expand Up @@ -45,6 +45,15 @@ package operations
_options = merge({uploadDataFieldName:"Filedata", testUpload:false}, options);
}

/**
* @inheritDoc
*/
override protected function cancelRequest():void
{
super.cancelRequest();
_file.cancel();
}

/**
* @inheritDoc
*/
Expand Down
4 changes: 2 additions & 2 deletions src/operations/NetworkOperation.as
Expand Up @@ -106,10 +106,10 @@ package operations
/**
* @inheritDoc
*/
final override public function fault(summary:String, detail:String = ""):void
final override public function fault(summary:String, detail:String = "", code:String = ""):void
{
stopTimeoutTimer();
super.fault(summary, detail);
super.fault(summary, detail, code);
}

private function handleAttemptTimerComplete(event:TimerEvent):void
Expand Down
7 changes: 4 additions & 3 deletions src/operations/Operation.as
Expand Up @@ -169,8 +169,9 @@ package operations
*
* @param summary A simple description of the fault.
* @param detail A more detailed description of the fault.
* @param code A code given to this fault.
*/
public function fault(summary:String, detail:String = ""):void
public function fault(summary:String, detail:String = "", code:String = ""):void
{
if (isExecuting) {
fireFault(summary, detail);
Expand Down Expand Up @@ -232,10 +233,10 @@ package operations
}
}

private function fireFault(summary:String, detail:String = ""):void
private function fireFault(summary:String, detail:String = "", code:String = ""):void
{
if (hasEventListener(FaultOperationEvent.FAULT)) {
dispatchEvent( new FaultOperationEvent(summary, detail) );
dispatchEvent( new FaultOperationEvent(summary, detail, code) );
}
}

Expand Down

0 comments on commit b61b935

Please sign in to comment.