Better error messages

query-exec-mode
Jack Christensen 2022-02-05 13:05:23 -06:00
parent 6ebf54b62b
commit 28ea2cd190
2 changed files with 12 additions and 2 deletions

View File

@ -250,7 +250,7 @@ func (c *ArrayCodec) decodeBinary(ci *ConnInfo, arrayOID uint32, src []byte, arr
}
err = elementScanPlan.Scan(elemSrc, elem)
if err != nil {
return err
return fmt.Errorf("failed to scan array element %d: %w", i, err)
}
}

View File

@ -489,7 +489,17 @@ type scanPlanFail struct {
}
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