ParticipantService - getSurveyParticipants() method - catch and serve an exception while fetching participants of given survey

This commit is contained in:
Meritoo
2017-09-29 15:18:31 +02:00
parent cd6dbf72bc
commit ab328b96ee
5 changed files with 188 additions and 6 deletions

View File

@@ -16,6 +16,13 @@ namespace Meritoo\LimeSurvey\ApiClient\Exception;
*/
class CannotProcessDataException extends \Exception
{
/**
* Reason why data cannot be processed, e.g. "Invalid user name or password"
*
* @var string
*/
private $reason;
/**
* Class constructor
*
@@ -23,9 +30,21 @@ class CannotProcessDataException extends \Exception
*/
public function __construct($reason)
{
$this->reason = $reason;
$template = 'Raw data returned by the LimeSurvey\'s API cannot be processed. Reason: \'%s\'.';
$message = sprintf($template, $reason);
$message = sprintf($template, $this->reason);
parent::__construct($message);
}
/**
* Returns reason why data cannot be processed, e.g. "Invalid user name or password"
*
* @return string
*/
public function getReason()
{
return $this->reason;
}
}