Repository navigation
Expand file tree
/
Copy pathExceptionHandler.php
More file actions
59 lines (51 loc) · 1.49 KB
/
Copy pathExceptionHandler.php
File metadata and controls
59 lines (51 loc) · 1.49 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
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact [email protected]
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\ExceptionHandler;
use Psr\Http\Message\ResponseInterface;
use Throwable;
abstract class ExceptionHandler
{
/**
* Determine if the exception should propagate to next handler.
*
* @var bool
*/
protected $propagationStopped = false;
/**
* Handle the exception, and return the specified result.
*/
abstract public function handle(Throwable $throwable, ResponseInterface $response);
/**
* Determine if the current exception handler should handle the exception,.
*
* @return bool
* If return true, then this exception handler will handle the exception,
* If return false, then delegate to next handler
*/
abstract public function isValid(Throwable $throwable): bool;
/**
* Stop propagate the exception to next handler.
*/
public function stopPropagation(): bool
{
$this->propagationStopped = true;
return $this->propagationStopped;
}
/**
* Is propagation stopped ?
* This will typically only be used by the handler to determine if the
* provious handler halted propagation.
*/
public function isPropagationStopped(): bool
{
return $this->propagationStopped;
}
}