izzum\statemachine\utils\Utils::wrapToStateMachineException PHP Метод

wrapToStateMachineException() публичный статический Метод

optionally throws it.
public static wrapToStateMachineException ( Exception $e, integer $code, $throw = false ) : Exception
$e Exception
$code integer
Результат izzum\statemachine\Exception
    public static function wrapToStateMachineException(\Exception $e, $code, $throw = false)
    {
        if (!is_a($e, 'izzum\\statemachine\\Exception')) {
            // wrap the exception and use the code provided.
            $e = new Exception($e->getMessage(), $code, $e);
        }
        if ($throw) {
            throw $e;
        }
        return $e;
    }

Usage Example

 /**
  * Always throws an izzum exception (converts a non-izzum exception to an
  * izzum exception)
  *
  * @param \Exception $e            
  * @param int $code
  *            if the exception is not of type Exception, wrap it and use
  *            this code.
  * @param Transition $transition
  *            optional. if set, we handle it as a transition exception too
  *            so it can be logged or handled
  * @throws Exception an izzum exception
  */
 protected function handlePossibleNonStatemachineException(\Exception $e, $code, $transition = null)
 {
     $e = Utils::wrapToStateMachineException($e, $code);
     if ($transition !== null) {
         $this->handleTransitionException($transition, $e);
     }
     throw $e;
 }
All Usage Examples Of izzum\statemachine\utils\Utils::wrapToStateMachineException