|
1
|
|
|
<?php namespace App\Modules\V1\Core\Utl; |
|
2
|
|
|
|
|
3
|
|
|
class ErrorHandler |
|
4
|
|
|
{ |
|
5
|
|
|
public function unAuthorized() |
|
6
|
|
|
{ |
|
7
|
|
|
$error = ['status' => 401, 'message' => trans('errors.unAuthorized')]; |
|
8
|
|
|
abort($error['status'], $error['message']); |
|
9
|
|
|
} |
|
10
|
|
|
|
|
11
|
|
|
public function tokenExpired() |
|
12
|
|
|
{ |
|
13
|
|
|
$error = ['status' => 403, 'message' => trans('errors.tokenExpired')]; |
|
14
|
|
|
abort($error['status'], $error['message']); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function noPermissions() |
|
18
|
|
|
{ |
|
19
|
|
|
$error = ['status' => 403, 'message' => trans('errors.noPermissions')]; |
|
20
|
|
|
abort($error['status'], $error['message']); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function loginFailed() |
|
24
|
|
|
{ |
|
25
|
|
|
$error = ['status' => 400, 'message' => trans('errors.loginFailed')]; |
|
26
|
|
|
abort($error['status'], $error['message']); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function redisNotRunning() |
|
30
|
|
|
{ |
|
31
|
|
|
$error = ['status' => 400, 'message' => trans('errors.redisNotRunning')]; |
|
32
|
|
|
abort($error['status'], $error['message']); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function dbQueryError() |
|
36
|
|
|
{ |
|
37
|
|
|
$error = ['status' => 400, 'message' => trans('errors.dbQueryError')]; |
|
38
|
|
|
abort($error['status'], $error['message']); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function cannotCreateSetting() |
|
42
|
|
|
{ |
|
43
|
|
|
$error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')]; |
|
44
|
|
|
abort($error['status'], $error['message']); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function cannotUpdateSettingKey() |
|
48
|
|
|
{ |
|
49
|
|
|
$error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')]; |
|
50
|
|
|
abort($error['status'], $error['message']); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function userIsBlocked() |
|
54
|
|
|
{ |
|
55
|
|
|
$error = ['status' => 403, 'message' => trans('errors.userIsBlocked')]; |
|
56
|
|
|
abort($error['status'], $error['message']); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function invalidResetToken() |
|
60
|
|
|
{ |
|
61
|
|
|
$error = ['status' => 400, 'message' => trans('errors.invalidResetToken')]; |
|
62
|
|
|
abort($error['status'], $error['message']); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function invalidResetPassword() |
|
66
|
|
|
{ |
|
67
|
|
|
$error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')]; |
|
68
|
|
|
abort($error['status'], $error['message']); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function invalidOldPassword() |
|
72
|
|
|
{ |
|
73
|
|
|
$error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')]; |
|
74
|
|
|
abort($error['status'], $error['message']); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function notFound($text) |
|
78
|
|
|
{ |
|
79
|
|
|
$error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])]; |
|
80
|
|
|
abort($error['status'], $error['message']); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function generalError() |
|
84
|
|
|
{ |
|
85
|
|
|
$error = ['status' => 404, 'message' => trans('errors.generalError')]; |
|
86
|
|
|
abort($error['status'], $error['message']); |
|
87
|
|
|
} |
|
88
|
|
|
} |