Daniel Shahaf added the comment:

> What's the reasoning behind offering a error code to name mapping?

Allowing code that runs into an error to print the error name rather than its
numeric value.  This saves whoever reads the error message having to look it up
himself.

> his seem problematic to me. In case a newer SQLite version introduces a new
> error code, this error code cannot be found in the mapping. I propose to
> leave this out in order to not have this problem.
> 
> Otherwise we will have people depending on any error code being able to be
> found in this mapping.

Then people shouldn't depend on the mapping being complete.  Let's keep the
mapping and document that people should only use it as
`sqlite3.errorcode.get(...)`, never as `sqlite3.errorcode[...]`.

Or if that's not a good API, we could encapsulate the incompleteness of the
mapping into a small wrapper function:

   def something(errorcode):
       return sqlite3.errorcode.get(errorcode,
                                    "<sqlite3 error {!d}>".format(errorcode))

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16379>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to