Skip to content

Commit ed3f921

Browse files
committed
feat: remove value from error messages
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
1 parent a3f8b22 commit ed3f921

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

‎errors.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type ParseError struct {
5353
}
5454

5555
func (e *ParseError) Error() string {
56-
return fmt.Sprintf("cannot parse '%s' as '%s': %s", e.Value, e.Expected.Type(), e.Err)
56+
return fmt.Sprintf("cannot parse value as '%s': %s", e.Expected.Type(), e.Err)
5757
}
5858

5959
func (*ParseError) mapstructure() {}
@@ -67,10 +67,9 @@ type UnconvertibleTypeError struct {
6767

6868
func (e *UnconvertibleTypeError) Error() string {
6969
return fmt.Sprintf(
70-
"expected type '%s', got unconvertible type '%s', value: '%v'",
70+
"expected type '%s', got unconvertible type '%s'",
7171
e.Expected.Type(),
7272
reflect.TypeOf(e.Value),
73-
e.Value,
7473
)
7574
}
7675

‎mapstructure_examples_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ func ExampleDecode_errors() {
6565
// Output:
6666
// decoding failed due to the following error(s):
6767
//
68-
// 'Name' expected type 'string', got unconvertible type 'int', value: '123'
69-
// 'Age' expected type 'int', got unconvertible type 'string', value: 'bad value'
70-
// 'Emails[0]' expected type 'string', got unconvertible type 'int', value: '1'
71-
// 'Emails[1]' expected type 'string', got unconvertible type 'int', value: '2'
72-
// 'Emails[2]' expected type 'string', got unconvertible type 'int', value: '3'
68+
// 'Name' expected type 'string', got unconvertible type 'int'
69+
// 'Age' expected type 'int', got unconvertible type 'string'
70+
// 'Emails[0]' expected type 'string', got unconvertible type 'int'
71+
// 'Emails[1]' expected type 'string', got unconvertible type 'int'
72+
// 'Emails[2]' expected type 'string', got unconvertible type 'int'
7373
}
7474

7575
func ExampleDecode_metadata() {

0 commit comments

Comments
 (0)