All database code using database/sql has to be database specific,
On Sunday, June 9, 2013 3:34:20 PM UTC+8, Jochen Voss wrote:

Dear Andy,

Many thanks for your answer.
On Sunday, 9 June 2013 01:17:06 UTC+2, Andy Balholm wrote:

The errors are specific to the database backend. At least some backends
define their own error type; for example
http://godoc.org/github.com/lib/pq#PGError . So use a type assertion or
type switch on the error; if it is the backend's database error type, check
to see if it is the specific kind of error that you're looking for.

This sounds painful! Are libraries using sql databases then forced to be
backend specific (if they do error handling)?

What I'm trying to do is to implement an account system, which stores user
information in a database. When somebody tries to add a new account, I
need to tell apart duplicate user names from other problems (like the DB
server being down, the table not existing, etc.) It would be great if
there was a backend-independent way of doing this.

Many thanks,
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 12 | next ›
Discussion Overview
groupgolang-nuts @
postedJun 8, '13 at 7:37p
activeJun 12, '13 at 7:29a



site design / logo © 2021 Grokbase