@@ -2,6 +2,7 @@ package errors_test
22
33import (
44 "fmt"
5+
56 "github.com/primalskill/errors"
67)
78
@@ -52,21 +53,20 @@ func ExampleError_PrettyPrint() {
5253func ExampleWithMeta () {
5354 // Valid
5455 mValid := errors .WithMeta ("key1" , 158 , "key2" , "some value" , "anotherKey" , true )
55-
5656 fmt .Printf ("%#v" , mValid )
5757
58- // Invalid Outputs
59- // errors.WithMeta(15) <-- results in compile error
60- // errors.WithMeta("noValueKey") <-- returns empty Meta map because there is no value added to noValueKey
61- // errors.WithMeta("key1", "value 1", 16, "key3", "key4", "some value") <-- skips 16 and key3 pairs because 16 is int and not string.
62- // errors.WithMeta("key1", "val1", 10, "val2", "key3") <-- skips 10 and val2 pairs, output: [key1:val1 key3:]
58+ // no value defined it will add !BADVALUE to noValueKey
59+ mBadValue := errors .WithMeta ("noValueKey" )
60+ fmt .Printf ("\n %#v" , mBadValue )
6361
64- // Output: errors.Meta{"anotherKey":true, "key1":158, "key2":"some value"}
65- }
62+ // 16 is not a string for a key it will replace it with !BADKEY2
63+ mBadKey := errors .WithMeta ("key1" , "val1" , 16 , "val2" , "key3" , "val3" )
64+ fmt .Printf ("\n %#v" , mBadKey )
6665
67- func ExampleWithMeta_emptyValue () {
68- mValid := errors .WithMeta ("key1" , "value1" , "key2" )
69- fmt .Printf ("%#v" , mValid )
66+ // 10 is not a string for a key it will replace it with !BADKEY2
67+ // key3 doesn't have a value it will add !BADVALUE to key3
68+ mBadKeyValue := errors .WithMeta ("key1" , "val1" , 10 , "val2" , "key3" )
69+ fmt .Printf ("\n %#v" , mBadKeyValue )
7070}
7171
7272func ExampleMeta_Merge () {
0 commit comments