[Gambas-user] gb3 database error handling
Bruce Bruen
bbruen at ...2308...
Tue Oct 11 02:47:12 CEST 2011
On Tue, 2011-10-11 at 01:58 +0200, Benoît Minisini wrote:
> > In the first line we see that db.Error=0 instead of the driver error
> > code, I would have expected 1022 (mysql error: "Error: 1022 SQLSTATE:
> > 23000 (ER_DUP_KEY) Message: Can't write; duplicate key in table '%s').
>
> I don't know why. The gb.db.mysql driver set the connection error code just
> after the query has been run by using a specific API of the mysql library.
>
Hmm. Yes, I've retried using postgresql and the dbms error code is
correctly returned.
> > Secondly, ..
:"-)
> > Thirdly, the gambas error code is -1? I thought that code was for
> > errors raised within the project i.e. Error.Raise(Message) I have used
> > that code (-1) to discern local vs system errors previously, is this no
> > longer safe?
>
> Gambas has always used "-1" error code for error raised by components and for
> Error.Raise() method.
OK, never noticed that before. Will have to adjust my practices.
> >
> > Finally, the error message itself seems to be not populated properly,
> > "Duplicate entry '' for key.." In my test case the key is multicolumn,
> > so this may be the reason. However, "Cannot create record: Duplicate
> > key for '<actual key name>' on table '<table name>'" would (IMO) be a
> > better message.
>
> This message comes from mysql. So I guess I can't fix it.
OK. (Just another reason for me to dislike the world's most popular Open Source bug-ridden rdbms)
regards
Bruce
-------------- next part --------------
A non-text attachment was scrubbed...
Name: face-embarrassed.png
Type: image/png
Size: 1067 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20111011/d8868756/attachment.png>
More information about the User
mailing list