blob: 9a8d66e2dc261b5121078b36e2a4f90e4ebeacdc (
plain) (
blame)
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
|
<?php
namespace LesserPHP;
/**
* An exception signalling a problem in the LESS source
*/
class ParserException extends \Exception
{
protected string $error = '';
protected string $culprit = '';
protected string $sourceFile = '';
protected int $sourceLine = -1;
public function __construct(
string $message = '',
?string $culprit = '',
?string $sourceFile = '',
?int $sourceLine = -1,
\Throwable $previous = null
) {
$this->error = $message;
if ($culprit) {
$this->culprit = $culprit;
$message .= " `$culprit`";
}
if ($sourceFile) {
$this->sourceFile = $sourceFile;
$message .= " in $sourceFile";
}
if ($sourceLine !== null && $sourceLine > -1) {
$this->sourceLine = $sourceLine;
$message .= " line: $sourceLine";
}
parent::__construct($message, 0, $previous);
}
/**
* This is the error message without any additional context
*/
public function getError(): string
{
return $this->error;
}
/**
* The LESS code that triggered the error
*
* This is the line the parser choked on. Not always available.
*/
public function getCulprit(): string
{
return $this->culprit;
}
/**
* The LESS source file where the error was triggered
*
* This is the file the parser was parsing, will usually only be available when
* parsing an import or when compileFile() was used.
*/
public function getSourceFile(): string
{
return $this->sourceFile;
}
/**
* The line number where the error was triggered
*/
public function getSourceLine(): int
{
return $this->sourceLine;
}
}
|