Re: [go-nuts] Analyse postgresql error

2022-10-27 Thread David Harel
Thanks. Exactly what I needed. On Wed, Oct 26, 2022 at 3:45 PM Konstantin Khomoutov wrote: > On Wed, Oct 26, 2022 at 01:38:51PM +0300, David Harel wrote: > > [...] > > func errorCheckResult(err error) string { > > if err == nil { > > return "" > > } > > pqerr := err.(*pq.Erro

Re: [go-nuts] Analyse postgresql error

2022-10-26 Thread Konstantin Khomoutov
On Wed, Oct 26, 2022 at 01:38:51PM +0300, David Harel wrote: [...] > func errorCheckResult(err error) string { > if err == nil { > return "" > } > pqerr := err.(*pq.Error) > switch pqerr.Get('C') { > case "23505": > return "Key violation" > } > return "E

Re: [go-nuts] Analyse postgresql error

2022-10-26 Thread David Harel
Thanks for your reply. After I submitted my question I made some progress and found that: The infrastructure of my solution is using the pq package - import " github.com/lib/pq" The marshaling method is not relevant anymore. I can analyse the error by casting to pq.Error. Code example: func erro

Re: [go-nuts] Analyse postgresql error

2022-10-25 Thread Konstantin Khomoutov
On Fri, Oct 21, 2022 at 08:17:16AM -0700, David Harel wrote: > Newbie on golang. Using sqlc: https://github.com/kyleconroy/sqlc in the > environment created by Karl Keefer: > https://github.com/karlkeefer/pngr/actions/workflows/build.yml, thanks Karl. > My queries use querier which is auto gener

[go-nuts] Analyse postgresql error

2022-10-21 Thread David Harel
Hi there, Newbie on golang. Using sqlc: https://github.com/kyleconroy/sqlc in the environment created by Karl Keefer: https://github.com/karlkeefer/pngr/actions/workflows/build.yml, thanks Karl. My queries use querier which is auto generated by sqlc. Sometime I get an error result in my query s