mirror of https://github.com/jackc/pgx.git
Better error messages
parent
6ebf54b62b
commit
28ea2cd190
|
@ -250,7 +250,7 @@ func (c *ArrayCodec) decodeBinary(ci *ConnInfo, arrayOID uint32, src []byte, arr
|
||||||
}
|
}
|
||||||
err = elementScanPlan.Scan(elemSrc, elem)
|
err = elementScanPlan.Scan(elemSrc, elem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed to scan array element %d: %w", i, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -489,7 +489,17 @@ type scanPlanFail struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plan *scanPlanFail) Scan(src []byte, dst interface{}) error {
|
func (plan *scanPlanFail) Scan(src []byte, dst interface{}) error {
|
||||||
return fmt.Errorf("cannot scan OID %v in format %v into %T", plan.oid, plan.formatCode, dst)
|
var format string
|
||||||
|
switch plan.formatCode {
|
||||||
|
case TextFormatCode:
|
||||||
|
format = "text"
|
||||||
|
case BinaryFormatCode:
|
||||||
|
format = "binary"
|
||||||
|
default:
|
||||||
|
format = fmt.Sprintf("unknown %d", plan.formatCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("cannot scan OID %v in %v format into %T", plan.oid, format, dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TryWrapScanPlanFunc is a function that tries to create a wrapper plan for target. If successful it returns a plan
|
// TryWrapScanPlanFunc is a function that tries to create a wrapper plan for target. If successful it returns a plan
|
||||||
|
|
Loading…
Reference in New Issue