tursodatabase / libsql-client-py

Python SDK for libSQL
https://libsql.org/libsql-client-py/
MIT License
44 stars 10 forks source link

LibsqlError should explcitly contain an explanation of the error #15

Open CodingDoug opened 1 year ago

CodingDoug commented 1 year ago
class LibsqlError(RuntimeError):
    code: str

    def __init__(self, message: str, code: str):
        super(RuntimeError, self).__init__(f"{code}: {message}")
        self.code = code

We have a code, which is normally the SQLite error code, such as SQLITE_CONSTRAINT, but the message of the error doesn't have representation here. The developer must dig into args to make some assumptions about what's there. It would be better if message was also a field here with the English explanation of the error.