/** * @param \Exception $dispatchException * @param array $pendingCommands * @return CommandDispatchException */ public static function wrap(\Exception $dispatchException, array $pendingCommands) { if ($dispatchException instanceof MessageDispatchException) { $ex = parent::failed($dispatchException->getFailedDispatchEvent(), $dispatchException->getPrevious()); $ex->pendingCommands = $pendingCommands; return $ex; } $ex = new static("Command dispatch failed. See previous exception for details.", 422, $dispatchException); $ex->pendingCommands = $pendingCommands; return $ex; }