Add contextual information to mapper errors.
This commit is contained in:
@@ -8,12 +8,11 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
|
||||
"github.com/chzyer/readline"
|
||||
"github.com/gliderlabs/ssh"
|
||||
"github.com/google/shlex"
|
||||
"github.com/kr/pty"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
|
||||
"github.com/alecthomas/colour"
|
||||
"github.com/alecthomas/kong"
|
||||
|
||||
@@ -253,10 +253,11 @@ func (v *Value) IsBool() bool {
|
||||
// Parse tokens into value, parse, and validate, but do not write to the field.
|
||||
func (v *Value) Parse(scan *Scanner, target reflect.Value) error {
|
||||
err := v.Mapper.Decode(&DecodeContext{Value: v, Scan: scan}, target)
|
||||
if err == nil {
|
||||
v.Set = true
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %s", v.Summary(), err)
|
||||
}
|
||||
return err
|
||||
v.Set = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// Apply value to field.
|
||||
|
||||
Reference in New Issue
Block a user