-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngineException.php
More file actions
44 lines (35 loc) · 1.35 KB
/
EngineException.php
File metadata and controls
44 lines (35 loc) · 1.35 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
<?php
declare(strict_types=1);
namespace PhpScript\Exceptions;
use RuntimeException;
use Throwable;
class EngineException extends RuntimeException
{
public function __construct(
string $message,
public int $line = 1,
public readonly int $column = 0,
public readonly int $offset = 0,
public readonly int $length = 1,
?Throwable $previous = null,
) {
parent::__construct($message, 0, $previous);
}
/**
* @codeCoverageIgnore
*/
public static function temporaryFileCreationFailed(): self
{
return new self('Temporary file creation failed.');
}
public static function runtimeError(string $message, int $line, int $column, int $offset, int $length, ?Throwable $previous = null): self
{
$message = sprintf('Runtime error: %s in line: %d, column: %d, offset: %d', $message, $line, $column, $offset);
return new self($message, $line, $column, $offset, $length, $previous);
}
public static function invalidFunctionCall(string $functionName, int $line, int $column, int $offset, int $length, ?Throwable $previous = null): self
{
$message = sprintf('Invalid function call: %s in line: %d, column: %d, offset: %d', $functionName, $line, $column, $offset);
return new self($message, $line, $column, $offset, $length, $previous);
}
}