packages/ztd-query-core/src/Exception/SqlParseException.php

1<?php
2
3declare(strict_types=1);
4
5namespace ZtdQuery\Exception;
6
7/**
8 * Exception thrown when SQL parsing fails due to syntax errors.
9 */
10final class SqlParseException extends SimulationException
11{
12    /**
13     * The SQL statement that failed to parse.
14     */
15    private string $sql;
16
17    /**
18     * The parse error message.
19     */
20    private string $parseError;
21
22    /**
23     * @param string $sql The SQL statement that failed to parse.
24     * @param string $parseError The parse error message.
25     */
26    public function __construct(string $sql, string $parseError)
27    {
28        parent::__construct(sprintf('SQL syntax error: %s', $parseError));
29        $this->sql = $sql;
30        $this->parseError = $parseError;
31    }
32
33    /**
34     * Get the SQL statement that failed to parse.
35     */
36    public function getSql(): string
37    {
38        return $this->sql;
39    }
40
41    /**
42     * Get the parse error message.
43     */
44    public function getParseError(): string
45    {
46        return $this->parseError;
47    }
48}
49