Total Complexity | 3 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class ValidationError extends Error implements ClientAware |
||
9 | { |
||
10 | /** |
||
11 | * The validator instance. |
||
12 | * |
||
13 | * @var \Illuminate\Contracts\Validation\Validator |
||
14 | */ |
||
15 | public $validator; |
||
16 | |||
17 | /** |
||
18 | * Create a new exception instance. |
||
19 | * |
||
20 | * @param \Illuminate\Contracts\Validation\Validator $validator |
||
21 | * @return void |
||
22 | */ |
||
23 | public function __construct($validator) |
||
24 | { |
||
25 | parent::__construct($validator->errors()->first()); |
||
26 | |||
27 | $this->validator = $validator; |
||
28 | $this->extensions['validation'] = $validator->errors(); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Returns true when exception message is safe to be displayed to a client. |
||
33 | * |
||
34 | * @return bool |
||
35 | * @api |
||
36 | */ |
||
37 | public function isClientSafe() |
||
38 | { |
||
39 | return true; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Returns string describing a category of the error. |
||
44 | * |
||
45 | * Value "graphql" is reserved for errors produced by query parsing or validation, do not use it. |
||
46 | * |
||
47 | * @return string |
||
48 | * @api |
||
49 | */ |
||
50 | public function getCategory() |
||
53 | } |
||
54 | } |
||
55 |