Skip to content

Commit

Permalink
RestException to include the stage at which it is thrown and successf…
Browse files Browse the repository at this point in the history
…ully completed and failed stages
  • Loading branch information
Arul- committed Jul 29, 2013
1 parent ebfa5a4 commit 45c522b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions RestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class RestException extends Exception
505 => 'HTTP Version Not Supported'
);
private $details;
private $stage;

/**
* @param string $httpStatusCode http status code
Expand All @@ -77,6 +78,8 @@ class RestException extends Exception
*/
public function __construct($httpStatusCode, $errorMessage = null, array $details = array(), Exception $previous = null)
{
$events = Util::$restler->_events;
$this->stage = end($events);
$this->details = $details;
parent::__construct($errorMessage, $httpStatusCode, $previous);
}
Expand All @@ -91,6 +94,21 @@ public function getDetails()
return $this->details;
}

public function getStage()
{
return $this->stage;
}

public function getStages()
{
$e = Util::$restler->_events;
$i = in_array($this->stage, $e);
return array(
'success' => array_slice($e, 0, $i),
'failure' => array_slice($e, $i),
);
}

public function getErrorMessage()
{
$statusCode = $this->getCode();
Expand Down

0 comments on commit 45c522b

Please sign in to comment.