Implement error struct
prochac opened this issue ยท 3 comments
Other sql drivers returns struct implementing error interface.
Ex.
https://pkg.go.dev/github.com/lib/pq#Error
https://pkg.go.dev/github.com/go-sql-driver/mysql#MySQLError
https://pkg.go.dev/github.com/jackc/pgconn#PgError
https://pkg.go.dev/github.com/denisenkom/go-mssqldb#Error
https://pkg.go.dev/github.com/snowflakedb/gosnowflake#SnowflakeError
Vertica returns pure string Error: [42V01] Relation "my_table" does not exist
The only possible way how to get the error code is parse the string, which is suboptimal.
And Unfortunately it is not possible if errors wrapping is used.
The fix goes into v1.2.1: https://pkg.go.dev/github.com/vertica/vertica-sql-go#VError
So I should use https://pkg.go.dev/github.com/vertica/vertica-sql-go#VError.SQLState, right?
The values are well known and documented.
https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/ErrorCodes/SQLStates.htm
What value contains https://pkg.go.dev/github.com/vertica/vertica-sql-go#VError.ErrorCode then?
Thanks for the pull request
@prochac The error code is described in https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/ErrorCodes/ErrorCodes.htm