Пример #1
0
 /**
  * ValidationException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  * @param  \Illuminate\Validation\Validator $validator
  * @param  array                            $errorCodes
  * @param  array                            $headers
  * @param  bool                          $report
  * @param  string                           $severity
  */
 public function __construct(IlluminateValidator $validator, array $errorCodes, array $headers = [], $report = false, $severity = 'error')
 {
     // Parse failed rules
     $failedRules = $this->parseFailedRules($validator->failed());
     // Set message of exception
     $errorMessages = $validator->errors();
     if ($errorMessages->count() > 1) {
         $message = 'Multiple validation rules failed. See "errors" for more details.';
     } else {
         $message = $errorMessages->first();
     }
     // Custom error codes container
     $customErrorCodes = [];
     // Custom error codes takes priority, so let's see
     // if one of our failed rules has one
     $failedRulesCustomErrorCodes = array_intersect(array_keys($errorCodes), $failedRules);
     if (!empty($failedRulesCustomErrorCodes)) {
         foreach ($failedRulesCustomErrorCodes as $failedRule) {
             $customErrorCodes[$errorCodes[$failedRule]] = $errorCodes[$failedRule];
         }
     }
     // Determine exception and status code
     $exceptionCode = $statusCode = !empty($customErrorCodes) ? array_shift($customErrorCodes) : 412;
     // Construct exception
     parent::__construct($message, $exceptionCode, $headers, $report, $severity);
     // Fill exception's error bag with validation errors
     $this->setErrors($errorMessages);
     // Set status code
     $this->setStatusCode($statusCode, $errorMessages->first());
     // Do not send report
     $this->dontReport();
 }
Пример #2
0
 /**
  * UnVerifiedException constructor.
  */
 public function __construct()
 {
     parent::__construct('User is not verified', 446);
     // Set status code
     $this->setStatusCode(446, 'Unverified');
     $this->dontReport();
 }
 /**
  * EntityNotFoundException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string   $message
  * @param  int  $code
  * @param  array    $headers
  * @param  bool  $report
  * @param  string   $severity
  */
 public function __construct($message, $code = 445, array $headers = [], $report = false, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
     // Set status code and status message
     $this->setStatusCode(445, 'Entity not found');
     // Should not report by default
     $this->dontReport();
 }
Пример #4
0
 /**
  * Exception constructor
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @access public
  * @param  object $data
  */
 public function __construct($data)
 {
     // Error message
     $message = sprintf('Error #%d. Reason: %s', $data->code, $data->message);
     // Add "more info" if available
     if (!empty($data->more_info)) {
         $message .= sprintf(' More info: %s', $data->more_info);
     }
     parent::__construct($message, $data->code, [], true);
 }
 /**
  * InvalidPushProvider constructor.
  *
  * @author Casper Rasmussen <*****@*****.**>
  * @param string $object
  */
 public function __construct($object)
 {
     if (is_object($object)) {
         $provider = get_class($object);
     } elseif (empty($object)) {
         $provider = 'NULL';
     } else {
         $provider = $object;
     }
     $message = sprintf('The push provider used [%s] is not an instance of ProviderInstance', $provider);
     parent::__construct($message, 500);
 }
 /**
  * GroupRulesNotFoundException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string   $message
  * @param  int  $code
  * @param  array    $headers
  * @param  bool  $report
  * @param  string   $severity
  */
 public function __construct($message = 'Validator not extending Laravel\'s validator', $code = 500, array $headers = [], $report = false, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
 }
 /**
  * GroupRulesNotFoundException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string   $message
  * @param  int  $code
  * @param  array    $headers
  * @param  bool  $report
  * @param  string   $severity
  */
 public function __construct($message = 'Validation group not found', $code = 500, array $headers = [], $report = false, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
 }
 /**
  * CounterCacheException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string   $message
  * @param  int  $code
  * @param  array    $headers
  * @param  bool  $report
  * @param  string   $severity
  */
 public function __construct($message = 'Counter cache failed', $code = 500, array $headers = [], $report = true, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
 }
Пример #9
0
 /**
  * InvalidTokenException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string   $message
  * @param  int  $code
  * @param  array    $headers
  * @param  bool  $report
  * @param  string   $severity
  */
 public function __construct($message = 'Invalid token', $code = 442, array $headers = [], $report = false, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
     // Set status code and status message
     $this->setStatusCode(442, 'Invalid token');
 }
Пример #10
0
 /**
  * MissingConfigException constructor.
  *
  * @param string $message
  */
 public function __construct($message)
 {
     parent::__construct($message, 500);
     $this->report();
 }
Пример #11
0
 /**
  * ResetPasswordNoUserException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string   $message
  * @param  int  $code
  * @param  array    $headers
  * @param  bool  $report
  * @param  string   $severity
  */
 public function __construct($message = 'No user found', $code = 445, array $headers = [], $report = false, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
     // Set status code and status message
     $this->setStatusCode(445);
 }
 /**
  * Constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string  $message
  * @param  int $statusCode
  * @param  string  $statusCodeMessage
  * @param  bool $report
  */
 public function __construct($message, $statusCode = 446, $statusCodeMessage = 'No user found', $report = false)
 {
     parent::__construct($message, $statusCode, $statusCodeMessage, $report);
 }
Пример #13
0
 /**
  * TokenExpiredException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string   $message
  * @param  int  $code
  * @param  array    $headers
  * @param  bool  $report
  * @param  string   $severity
  */
 public function __construct($message, $code = 401, array $headers = [], $report = false, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
     // Set status code
     $this->setStatusCode(401);
 }
Пример #14
0
 /**
  * InvalidPasswordException constructor.
  *
  * @author Casper Rasmussen <*****@*****.**>
  *
  * @param  string  $message   Error message
  * @param  mixed   $code      Error code
  * @param  array   $headers   List of headers
  * @param  bool $report    Wether or not exception should be reported
  * @param  string  $severity  Options: "fatal", "error", "warning", "info"
  */
 public function __construct($message = 'Invalid password', $code = 400, $headers = [], $report = true, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
 }
 /**
  * ApplicationNotFoundException constructor.
  *
  * @author Casper Rasmussen <*****@*****.**>
  * @param string $message
  */
 public function __construct($message)
 {
     parent::__construct($message, 500);
 }
Пример #16
0
 /**
  * MissingUserModelException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string   $message
  * @param  int  $code
  * @param  array    $headers
  * @param  bool  $report
  * @param  string   $severity
  */
 public function __construct($message = 'Missing user model for authentication', $code = 500, array $headers = [], $report = false, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
     // Set status code and status message
     $this->setStatusCode(500, 'Missing user model for authentication');
 }
 /**
  * AssetsUploadFailedException constructor
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @access public
  * @param  string  $message
  * @param  integer $code
  * @param  array   $headers
  * @param  boolean $report
  */
 public function __construct($message, $code = 500, $headers = [], $report = false)
 {
     parent::__construct($message, $code, $headers, $report);
 }
Пример #18
0
 /**
  * SaveFailedException constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string   $message
  * @param  int  $code
  * @param  array    $headers
  * @param  bool  $report
  * @param  string   $severity
  */
 public function __construct($message, $code = 550, array $headers = [], $report = true, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
     // Set status code and status message
     $this->setStatusCode(550, 'Could not save to database');
 }
Пример #19
0
 /**
  * UnknownResourceException constructor
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @access public
  * @param  string  $message  Error message
  * @param  integer $code     Error code
  * @param  array   $headers  List of headers
  * @param  boolean $report   Whether or not exception should be reported
  */
 public function __construct($message = 'Unknown resource', $code = 400, $headers = [], $report = false)
 {
     parent::__construct($message, $code, $headers, $report);
 }
Пример #20
0
 /**
  * InvalidUserAgent constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  string  $message   Error message
  * @param  int $code      Error code
  * @param  array   $headers   List of headers
  * @param  bool $report    Wether or not exception should be reported
  * @param  string  $severity  Options: "fatal", "error", "warning", "info"
  */
 public function __construct($message, $code, $headers = [], $report = true, $severity = 'error')
 {
     parent::__construct($message, $code, $headers, $report, $severity);
 }