Permalink
Browse files

Added Exception classes

  • Loading branch information...
1 parent 92eec6f commit ce9c75b10780d73e4567ba1367a91189e2814cf2 @jeremyFreeAgent committed Jun 4, 2012
Showing with 24 additions and 4 deletions.
  1. +9 −0 Exception/ValidationException.php
  2. +9 −0 Exception/WorkflowException.php
  3. +6 −4 Manager/Manager.php
View
9 Exception/ValidationException.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace FreeAgent\WorkflowBundle\Exception;
+
+
+class ValidationException extends \Exception
+{
+
+}
View
9 Exception/WorkflowException.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace FreeAgent\WorkflowBundle\Exception;
+
+
+class WorkflowException extends \Exception
+{
+
+}
View
10 Manager/Manager.php
@@ -6,6 +6,8 @@
use FreeAgent\WorkflowBundle\Model\ModelInterface;
use FreeAgent\WorkflowBundle\Step\Collection as StepCollection;
use FreeAgent\WorkflowBundle\Step\Step;
+use FreeAgent\WorkflowBundle\Exception\ValidationException;
+use FreeAgent\WorkflowBundle\Exception\WorkflowException;
class Manager
{
@@ -49,12 +51,12 @@ public function configureWorkflow($workflowName)
$this->workflow = $this->container->getParameter('free_agent_workflow.workflows.'.$this->workflowName, null);
if (is_null($this->workflow)) {
- throw new \Exception('The workflow "'.$this->workflowName.'" does not exist');
+ throw new WorkflowException('The workflow "'.$this->workflowName.'" does not exist');
}
$defaultStep = $this->workflow['default_step'];
if (!array_key_exists($defaultStep, $this->workflow['steps'])) {
- throw new \Exception('The default step of "'.$this->workflowName.'" does not exist');
+ throw new WorkflowException('The default step of "'.$this->workflowName.'" does not exist');
}
foreach ($this->workflow['steps'] as $stepName => $stepConfiguration) {
@@ -102,7 +104,7 @@ public function getSteps()
public function getStep($stepName)
{
if (!$this->getSteps()->offsetExists($stepName)) {
- throw new \Exception('Step with name "'.$stepName.'" is not in "'.$this->workflowName.'" workflow');
+ throw new WorkflowException('Step with name "'.$stepName.'" is not in "'.$this->workflowName.'" workflow');
}
return $this->getSteps()->offsetGet($stepName);
@@ -182,7 +184,7 @@ public function canReachStep($stepName)
try {
$validation->validate($this->getModel());
$this->canReachStep[$stepToReach->getName()] = true;
- } catch (\Exception $e) {
+ } catch (ValidationException $e) {
$this->validationErrors[$stepToReach->getName()][] = $e->getMessage();
$this->canReachStep[$stepToReach->getName()] = false;
}

0 comments on commit ce9c75b

Please sign in to comment.