Better error messages
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-1
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user