-
-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathexceptions.php
More file actions
99 lines (74 loc) · 1.79 KB
/
exceptions.php
File metadata and controls
99 lines (74 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
declare(strict_types=1);
namespace Nette\Application;
use Nette\Http;
/**
* The exception that is thrown when user attempts to terminate the current presenter or application.
* This is special "silent exception" with no error message or code.
*/
class AbortException extends \Exception
{
}
/**
* Application fatal error.
*/
class ApplicationException extends \Exception
{
}
/**
* The exception that is thrown when a presenter cannot be loaded.
*/
class InvalidPresenterException extends \Exception
{
}
/**
* The exception that indicates client error with HTTP code 4xx.
*/
class BadRequestException extends \Exception
{
/** @var int */
protected $code = Http\IResponse::S404_NOT_FOUND;
public function __construct(string $message = '', int $httpCode = 0, \Exception $previous = null)
{
parent::__construct($message, $httpCode ?: $this->code, $previous);
}
public function getHttpCode(): int
{
return $this->code;
}
}
/**
* Forbidden request exception - access denied.
*/
class ForbiddenRequestException extends BadRequestException
{
/** @var int */
protected $code = Http\IResponse::S403_FORBIDDEN;
}
/**
* The exception that indicates request rejected by framework.
*/
class RejectRequestException extends UI\BadSignalException
{
public const NO_ROUTE = 1;
public const WRONG_PRESENTER = 2;
public const WRONG_SIGNAL = 3;
public const WRONG_ARGUMENT = 4;
/** @var int */
private $reason;
public function __construct($message, $reason, \Exception $previous = null)
{
parent::__construct($message, Http\IResponse::S404_NOT_FOUND, $previous);
}
/**
* @return int
*/
public function getReason()
{
return $this->reason;
}
}