Skip to content
Snippets Groups Projects
Commit 66a62d12 authored by jaapjansma's avatar jaapjansma
Browse files

improved exception handling.

parent ccb0bab1
No related branches found
No related tags found
No related merge requests found
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\FormProcessor\API;
use Throwable;
class Exception extends \Exception {
public function __construct($actionName, Throwable $previous = NULL) {
$message = "Action ".$actionName." failed.";
if ($previous) {
$message .= " Caused by ".$previous->getMessage();
}
parent::__construct($message, null, $previous);
}
}
\ No newline at end of file
......@@ -204,9 +204,13 @@
} else {
// There is no delay. Execute the action immediately
// Now execute the action
$outputBag = $actionClass->execute($mappedParameterBag, $mappedConditionParameterBag, $mappedConditionOutputParameterBag);
// Add the output of the action to the data bag of this action.
$dataBag->setActionDataFromActionProviderParameterBag($objAction, $outputBag);
try {
$outputBag = $actionClass->execute($mappedParameterBag, $mappedConditionParameterBag, $mappedConditionOutputParameterBag);
// Add the output of the action to the data bag of this action.
$dataBag->setActionDataFromActionProviderParameterBag($objAction, $outputBag);
} catch (\Exception $e) {
throw new Exception($action['title'], $e);
}
}
}
......
......@@ -177,11 +177,14 @@
$condition = \CRM_FormProcessor_Condition::getConditionClass($action['condition_configuration']);
$actionClass->setCondition($condition);
// Now execute the action
$outputBag = $actionClass->execute($mappedParameterBag, $mappedConditionParameterBag, $mappedConditionOutputParameterBag);
// Add the output of the action to the data bag of this action.
$dataBag->setActionDataFromActionProviderParameterBag($objAction, $outputBag);
try {
// Now execute the action
$outputBag = $actionClass->execute($mappedParameterBag, $mappedConditionParameterBag, $mappedConditionOutputParameterBag);
// Add the output of the action to the data bag of this action.
$dataBag->setActionDataFromActionProviderParameterBag($objAction, $outputBag);
} catch (\Exception $e) {
throw new Exception($action['title'], $e);
}
}
$return = array();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment