aboutsummaryrefslogtreecommitdiff
path: root/src/DBError.php
blob: 4860d2f368e8c592f1bd116dc2ebfae8d5dcd90a (plain)
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
<?php


namespace Micropoly;


use Exception;

class DBError extends Exception
{
    private string $msg;
    private string $sql;

    /**
     * DBError constructor.
     * @param string $msg
     * @param string $sql
     */
    public function __construct(string $msg, string $sql)
    {
        $this->msg = $msg;
        $this->sql = $sql;

        parent::__construct($this->buildMessage());
    }

    private function buildMessage(): string
    {
        return "{$this->msg}. SQL was: {$this->sql}";
    }
}