spotorm / spot2

Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer
http://phpdatamapper.com
BSD 3-Clause "New" or "Revised" License
601 stars 101 forks source link

It seems to me that it could be improved error exceptions with the code returned by the database #268

Open dertin opened 6 years ago

dertin commented 6 years ago

I did not find exactly where this extra information could be added which is useful when evaluating the type of error by means of a code.

try {
    throw new Exception("Can't write; duplicate key in table", 1022);
} catch(Exception $e) {
    echo "The exception code is: " . $e->getCode();
}

https://dev.mysql.com/doc/refman/8.0/en/error-messages-server.html https://www.postgresql.org/docs/current/static/errcodes-appendix.html

FlipEverything commented 6 years ago

+1