-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathException.php
More file actions
69 lines (58 loc) · 1.61 KB
/
Copy pathException.php
File metadata and controls
69 lines (58 loc) · 1.61 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
<?php
declare(strict_types=1);
/* (c) Anton Medvedev <anton@medv.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer\Exception;
use Throwable;
class Exception extends \Exception
{
/**
* @var string
*/
private static $taskSourceLocation = '';
/**
* @var string
*/
private $taskFilename = '';
/**
* @var int|mixed
*/
private $taskLineNumber = 0;
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
{
if (function_exists('debug_backtrace')) {
$trace = debug_backtrace();
foreach ($trace as $t) {
if (!empty($t['file']) && $t['file'] === self::$taskSourceLocation) {
$this->taskFilename = basename($t['file']);
$this->taskLineNumber = $t['line'];
break;
}
}
}
parent::__construct($message, $code, $previous);
}
public static function setTaskSourceLocation(string $filepath): void
{
self::$taskSourceLocation = $filepath;
}
public function getTaskFilename(): string
{
return $this->taskFilename;
}
public function getTaskLineNumber(): int
{
return $this->taskLineNumber;
}
public function setTaskFilename(string $taskFilename): void
{
$this->taskFilename = $taskFilename;
}
public function setTaskLineNumber(int $taskLineNumber): void
{
$this->taskLineNumber = $taskLineNumber;
}
}