imagecms/ImageCMS

View on GitHub
application/modules/callbacks/Exceptions/ValidationException.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
namespace callbacks\Exceptions;

class ValidationException extends \Exception
{

    /**
     * @var array
     */
    protected $validationErrors;

    /**
     * Construct the exception. Note: The message is NOT binary safe.
     * @link http://php.net/manual/en/exception.construct.php
     * @param string $message [optional] The Exception message to throw.
     * @param int $code [optional] The Exception code.
     * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
     * @since 5.1.0
     */
    public function __construct($message = '', $code = 0, Exception $previous = null) {
        $validation_message = isset($message['message']) ? $message['message'] : '';
        $this->validationErrors = isset($message['errors']) && is_array($message['errors']) ? $message['errors'] : [];
        parent::__construct($validation_message, $code, $previous);
    }

    /**
     * @return array validation errors field name => error
     */
    public function getValidationErrors() {
        return $this->validationErrors;
    }

}