Documentation
¶
Overview ¶
Package mysql provides an errs.Classifier for errors originating from the go-sql-driver/mysql driver and the standard database/sql + net packages commonly seen when talking to a MySQL backend.
The classifier inspects a single error node at a time, as required by the errs.Classifier contract. It returns errs.Unknown for nodes it does not recognise so the surrounding errs.Classify chain walk can continue to deeper nodes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Classifier errs.Classifier = classifier{}
Classifier implements errs.Classifier for MySQL-related errors. It recognises:
- *gomysql.MySQLError values, dispatching on the server-reported error number to one of InfraRetryable (transient server / lock / connection issues) or Infra (everything else the driver reports — schema bugs, constraint violations, programmer errors).
- driver.ErrBadConn and sql.ErrConnDone — pooled connection failures that are safe to retry on a fresh connection.
- sql.ErrTxDone — a programming error, non-retryable.
- net.Error values (including *net.OpError, *net.DNSError) — transient network failures while talking to the server, retryable.
Anything else returns errs.Unknown so the surrounding errs.Classify walker can keep looking down the unwrap chain.
The classifier never returns errs.User. Constraint violations and similar codes that a caller might want to surface as user errors must be wrapped explicitly with errs.NewUserError at the controller — only the controller knows whether a duplicate key, FK violation, etc. reflects bad input from the user or an internal invariant being broken. The framework-wrap check in errs.Classify short-circuits before this classifier runs, so an explicit controller wrap always wins.
The classifier is stateless; this package-level singleton is the canonical handle. Pass it into errs.Classify (typically as a vararg to consumer.New).
Functions ¶
This section is empty.
Types ¶
This section is empty.