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