@@ -167,22 +167,7 @@ func (e *InvalidUnmarshalError) Error() string {
167
167
return "json: Unmarshal(nil " + e .Type .String () + ")"
168
168
}
169
169
170
- // jsonError is an error wrapper type for internal use only.
171
- // Panics with errors are wrapped in jsonError so that the top-level recover
172
- // can distinguish intentional panics from this package.
173
- type jsonError struct { error }
174
-
175
- func (d * decodeState ) unmarshal (v interface {}) (err error ) {
176
- defer func () {
177
- if r := recover (); r != nil {
178
- if je , ok := r .(jsonError ); ok {
179
- err = je .error
180
- } else {
181
- panic (r )
182
- }
183
- }
184
- }()
185
-
170
+ func (d * decodeState ) unmarshal (v interface {}) error {
186
171
rv := reflect .ValueOf (v )
187
172
if rv .Kind () != reflect .Ptr || rv .IsNil () {
188
173
return & InvalidUnmarshalError {reflect .TypeOf (v )}
@@ -192,7 +177,10 @@ func (d *decodeState) unmarshal(v interface{}) (err error) {
192
177
d .scanWhile (scanSkipSpace )
193
178
// We decode rv not rv.Elem because the Unmarshaler interface
194
179
// test must be applied at the top level of the value.
195
- d .value (rv )
180
+ err := d .value (rv )
181
+ if err != nil {
182
+ return err
183
+ }
196
184
return d .savedError
197
185
}
198
186
@@ -306,11 +294,6 @@ func (d *decodeState) init(data []byte) *decodeState {
306
294
return d
307
295
}
308
296
309
- // error aborts the decoding by panicking with err wrapped in jsonError.
310
- func (d * decodeState ) error (err error ) {
311
- panic (jsonError {d .addErrorContext (err )})
312
- }
313
-
314
297
// saveError saves the first err it is called with,
315
298
// for reporting at the end of the unmarshal.
316
299
func (d * decodeState ) saveError (err error ) {
@@ -380,22 +363,26 @@ func (d *decodeState) scanWhile(op int) {
380
363
// value consumes a JSON value from d.data[d.off-1:], decoding into v, and
381
364
// reads the following byte ahead. If v is invalid, the value is discarded.
382
365
// The first byte of the value has been read already.
383
- func (d * decodeState ) value (v reflect.Value ) {
366
+ func (d * decodeState ) value (v reflect.Value ) error {
384
367
switch d .opcode {
385
368
default :
386
- d . error ( errPhase )
369
+ return errPhase
387
370
388
371
case scanBeginArray :
389
372
if v .IsValid () {
390
- d .array (v )
373
+ if err := d .array (v ); err != nil {
374
+ return err
375
+ }
391
376
} else {
392
377
d .skip ()
393
378
}
394
379
d .scanNext ()
395
380
396
381
case scanBeginObject :
397
382
if v .IsValid () {
398
- d .object (v )
383
+ if err := d .object (v ); err != nil {
384
+ return err
385
+ }
399
386
} else {
400
387
d .skip ()
401
388
}
@@ -407,9 +394,12 @@ func (d *decodeState) value(v reflect.Value) {
407
394
d .scanWhile (scanContinue )
408
395
409
396
if v .IsValid () {
410
- d .literalStore (d .data [start :d .readIndex ()], v , false )
397
+ if err := d .literalStore (d .data [start :d .readIndex ()], v , false ); err != nil {
398
+ return err
399
+ }
411
400
}
412
401
}
402
+ return nil
413
403
}
414
404
415
405
type unquotedValue struct {}
@@ -418,10 +408,10 @@ type unquotedValue struct{}
418
408
// quoted string literal or literal null into an interface value.
419
409
// If it finds anything other than a quoted string literal or null,
420
410
// valueQuoted returns unquotedValue{}.
421
- func (d * decodeState ) valueQuoted () interface {} {
411
+ func (d * decodeState ) valueQuoted () ( interface {}, error ) {
422
412
switch d .opcode {
423
413
default :
424
- d . error ( errPhase )
414
+ return nil , errPhase
425
415
426
416
case scanBeginArray :
427
417
d .skip ()
@@ -432,12 +422,16 @@ func (d *decodeState) valueQuoted() interface{} {
432
422
d .scanNext ()
433
423
434
424
case scanBeginLiteral :
435
- switch v := d .literalInterface ().(type ) {
425
+ v , err := d .literalInterface ()
426
+ if err != nil {
427
+ return nil , err
428
+ }
429
+ switch v .(type ) {
436
430
case nil , string :
437
- return v
431
+ return v , nil
438
432
}
439
433
}
440
- return unquotedValue {}
434
+ return unquotedValue {}, nil
441
435
}
442
436
443
437
// indirect walks down v allocating pointers as needed,
@@ -511,22 +505,18 @@ func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnm
511
505
512
506
// array consumes an array from d.data[d.off-1:], decoding into v.
513
507
// The first byte of the array ('[') has been read already.
514
- func (d * decodeState ) array (v reflect.Value ) {
508
+ func (d * decodeState ) array (v reflect.Value ) error {
515
509
// Check for unmarshaler.
516
510
u , ut , pv := indirect (v , false )
517
511
if u != nil {
518
512
start := d .readIndex ()
519
513
d .skip ()
520
- err := u .UnmarshalJSON (d .data [start :d .off ])
521
- if err != nil {
522
- d .error (err )
523
- }
524
- return
514
+ return u .UnmarshalJSON (d .data [start :d .off ])
525
515
}
526
516
if ut != nil {
527
517
d .saveError (& UnmarshalTypeError {Value : "array" , Type : v .Type (), Offset : int64 (d .off )})
528
518
d .skip ()
529
- return
519
+ return nil
530
520
}
531
521
v = pv
532
522
@@ -535,15 +525,19 @@ func (d *decodeState) array(v reflect.Value) {
535
525
case reflect .Interface :
536
526
if v .NumMethod () == 0 {
537
527
// Decoding into nil interface? Switch to non-reflect code.
538
- v .Set (reflect .ValueOf (d .arrayInterface ()))
539
- return
528
+ ai , err := d .arrayInterface ()
529
+ if err != nil {
530
+ return err
531
+ }
532
+ v .Set (reflect .ValueOf (ai ))
533
+ return nil
540
534
}
541
535
// Otherwise it's invalid.
542
536
fallthrough
543
537
default :
544
538
d .saveError (& UnmarshalTypeError {Value : "array" , Type : v .Type (), Offset : int64 (d .off )})
545
539
d .skip ()
546
- return
540
+ return nil
547
541
case reflect .Array :
548
542
case reflect .Slice :
549
543
break
@@ -576,10 +570,14 @@ func (d *decodeState) array(v reflect.Value) {
576
570
577
571
if i < v .Len () {
578
572
// Decode into element.
579
- d .value (v .Index (i ))
573
+ if err := d .value (v .Index (i )); err != nil {
574
+ return err
575
+ }
580
576
} else {
581
577
// Ran out of fixed array: skip.
582
- d .value (reflect.Value {})
578
+ if err := d .value (reflect.Value {}); err != nil {
579
+ return err
580
+ }
583
581
}
584
582
i ++
585
583
@@ -591,7 +589,7 @@ func (d *decodeState) array(v reflect.Value) {
591
589
break
592
590
}
593
591
if d .opcode != scanArrayValue {
594
- d . error ( errPhase )
592
+ return errPhase
595
593
}
596
594
}
597
595
@@ -609,36 +607,37 @@ func (d *decodeState) array(v reflect.Value) {
609
607
if i == 0 && v .Kind () == reflect .Slice {
610
608
v .Set (reflect .MakeSlice (v .Type (), 0 , 0 ))
611
609
}
610
+ return nil
612
611
}
613
612
614
613
var nullLiteral = []byte ("null" )
615
614
var textUnmarshalerType = reflect .TypeOf (new (encoding.TextUnmarshaler )).Elem ()
616
615
617
616
// object consumes an object from d.data[d.off-1:], decoding into v.
618
617
// The first byte ('{') of the object has been read already.
619
- func (d * decodeState ) object (v reflect.Value ) {
618
+ func (d * decodeState ) object (v reflect.Value ) error {
620
619
// Check for unmarshaler.
621
620
u , ut , pv := indirect (v , false )
622
621
if u != nil {
623
622
start := d .readIndex ()
624
623
d .skip ()
625
- err := u .UnmarshalJSON (d .data [start :d .off ])
626
- if err != nil {
627
- d .error (err )
628
- }
629
- return
624
+ return u .UnmarshalJSON (d .data [start :d .off ])
630
625
}
631
626
if ut != nil {
632
627
d .saveError (& UnmarshalTypeError {Value : "object" , Type : v .Type (), Offset : int64 (d .off )})
633
628
d .skip ()
634
- return
629
+ return nil
635
630
}
636
631
v = pv
637
632
638
633
// Decoding into nil interface? Switch to non-reflect code.
639
634
if v .Kind () == reflect .Interface && v .NumMethod () == 0 {
640
- v .Set (reflect .ValueOf (d .objectInterface ()))
641
- return
635
+ oi , err := d .objectInterface ()
636
+ if err != nil {
637
+ return err
638
+ }
639
+ v .Set (reflect .ValueOf (oi ))
640
+ return nil
642
641
}
643
642
644
643
// Check type of target:
@@ -658,7 +657,7 @@ func (d *decodeState) object(v reflect.Value) {
658
657
if ! reflect .PtrTo (t .Key ()).Implements (textUnmarshalerType ) {
659
658
d .saveError (& UnmarshalTypeError {Value : "object" , Type : v .Type (), Offset : int64 (d .off )})
660
659
d .skip ()
661
- return
660
+ return nil
662
661
}
663
662
}
664
663
if v .IsNil () {
@@ -669,7 +668,7 @@ func (d *decodeState) object(v reflect.Value) {
669
668
default :
670
669
d .saveError (& UnmarshalTypeError {Value : "object" , Type : v .Type (), Offset : int64 (d .off )})
671
670
d .skip ()
672
- return
671
+ return nil
673
672
}
674
673
675
674
var mapElem reflect.Value
@@ -682,7 +681,7 @@ func (d *decodeState) object(v reflect.Value) {
682
681
break
683
682
}
684
683
if d .opcode != scanBeginLiteral {
685
- d . error ( errPhase )
684
+ return errPhase
686
685
}
687
686
688
687
// Read key.
@@ -691,7 +690,7 @@ func (d *decodeState) object(v reflect.Value) {
691
690
item := d .data [start :d .readIndex ()]
692
691
key , ok := unquoteBytes (item )
693
692
if ! ok {
694
- d . error ( errPhase )
693
+ return errPhase
695
694
}
696
695
697
696
// Figure out field corresponding to key.
@@ -756,21 +755,31 @@ func (d *decodeState) object(v reflect.Value) {
756
755
d .scanWhile (scanSkipSpace )
757
756
}
758
757
if d .opcode != scanObjectKey {
759
- d . error ( errPhase )
758
+ return errPhase
760
759
}
761
760
d .scanWhile (scanSkipSpace )
762
761
763
762
if destring {
764
- switch qv := d .valueQuoted ().(type ) {
763
+ q , err := d .valueQuoted ()
764
+ if err != nil {
765
+ return err
766
+ }
767
+ switch qv := q .(type ) {
765
768
case nil :
766
- d .literalStore (nullLiteral , subv , false )
769
+ if err := d .literalStore (nullLiteral , subv , false ); err != nil {
770
+ return err
771
+ }
767
772
case string :
768
- d .literalStore ([]byte (qv ), subv , true )
773
+ if err := d .literalStore ([]byte (qv ), subv , true ); err != nil {
774
+ return err
775
+ }
769
776
default :
770
777
d .saveError (fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal unquoted value into %v" , subv .Type ()))
771
778
}
772
779
} else {
773
- d .value (subv )
780
+ if err := d .value (subv ); err != nil {
781
+ return err
782
+ }
774
783
}
775
784
776
785
// Write value back to map;
@@ -783,7 +792,9 @@ func (d *decodeState) object(v reflect.Value) {
783
792
kv = reflect .ValueOf (key ).Convert (kt )
784
793
case reflect .PtrTo (kt ).Implements (textUnmarshalerType ):
785
794
kv = reflect .New (v .Type ().Key ())
786
- d .literalStore (item , kv , true )
795
+ if err := d .literalStore (item , kv , true ); err != nil {
796
+ return err
797
+ }
787
798
kv = kv .Elem ()
788
799
default :
789
800
switch kt .Kind () {
@@ -792,15 +803,15 @@ func (d *decodeState) object(v reflect.Value) {
792
803
n , err := strconv .ParseInt (s , 10 , 64 )
793
804
if err != nil || reflect .Zero (kt ).OverflowInt (n ) {
794
805
d .saveError (& UnmarshalTypeError {Value : "number " + s , Type : kt , Offset : int64 (start + 1 )})
795
- return
806
+ return nil
796
807
}
797
808
kv = reflect .ValueOf (n ).Convert (kt )
798
809
case reflect .Uint , reflect .Uint8 , reflect .Uint16 , reflect .Uint32 , reflect .Uint64 , reflect .Uintptr :
799
810
s := string (key )
800
811
n , err := strconv .ParseUint (s , 10 , 64 )
801
812
if err != nil || reflect .Zero (kt ).OverflowUint (n ) {
802
813
d .saveError (& UnmarshalTypeError {Value : "number " + s , Type : kt , Offset : int64 (start + 1 )})
803
- return
814
+ return nil
804
815
}
805
816
kv = reflect .ValueOf (n ).Convert (kt )
806
817
default :
@@ -818,12 +829,13 @@ func (d *decodeState) object(v reflect.Value) {
818
829
break
819
830
}
820
831
if d .opcode != scanObjectValue {
821
- d . error ( errPhase )
832
+ return errPhase
822
833
}
823
834
824
835
d .errorContext .Struct = ""
825
836
d .errorContext .Field = ""
826
837
}
838
+ return nil
827
839
}
828
840
829
841
// convertNumber converts the number literal s to a float64 or a Number
@@ -846,21 +858,21 @@ var numberType = reflect.TypeOf(Number(""))
846
858
// fromQuoted indicates whether this literal came from unwrapping a
847
859
// string from the ",string" struct tag option. this is used only to
848
860
// produce more helpful error messages.
849
- func (d * decodeState ) literalStore (item []byte , v reflect.Value , fromQuoted bool ) {
861
+ func (d * decodeState ) literalStore (item []byte , v reflect.Value , fromQuoted bool ) error {
850
862
// Check for unmarshaler.
851
863
if len (item ) == 0 {
852
864
//Empty string given
853
865
d .saveError (fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal %q into %v" , item , v .Type ()))
854
- return
866
+ return nil
855
867
}
856
868
isNull := item [0 ] == 'n' // null
857
869
u , ut , pv := indirect (v , isNull )
858
870
if u != nil {
859
871
err := u .UnmarshalJSON (item )
860
872
if err != nil {
861
- d . error ( err )
873
+ return err
862
874
}
863
- return
875
+ return nil
864
876
}
865
877
if ut != nil {
866
878
if item [0 ] != '"' {
@@ -878,21 +890,21 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool
878
890
}
879
891
d .saveError (& UnmarshalTypeError {Value : val , Type : v .Type (), Offset : int64 (d .readIndex ())})
880
892
}
881
- return
893
+ return nil
882
894
}
883
895
s , ok := unquoteBytes (item )
884
896
if ! ok {
885
897
if fromQuoted {
886
- d . error ( fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal %q into %v" , item , v .Type () ))
898
+ return fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal %q into %v" , item , v .Type ())
887
899
} else {
888
- d . error ( errPhase )
900
+ return errPhase
889
901
}
890
902
}
891
903
err := ut .UnmarshalText (s )
892
904
if err != nil {
893
- d . error ( err )
905
+ return err
894
906
}
895
- return
907
+ return nil
896
908
}
897
909
898
910
v = pv
@@ -939,9 +951,9 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool
939
951
s , ok := unquoteBytes (item )
940
952
if ! ok {
941
953
if fromQuoted {
942
- d . error ( fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal %q into %v" , item , v .Type () ))
954
+ return fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal %q into %v" , item , v .Type ())
943
955
} else {
944
- d . error ( errPhase )
956
+ return errPhase
945
957
}
946
958
}
947
959
switch v .Kind () {
@@ -972,9 +984,9 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool
972
984
default : // number
973
985
if c != '-' && (c < '0' || c > '9' ) {
974
986
if fromQuoted {
975
- d . error ( fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal %q into %v" , item , v .Type () ))
987
+ return fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal %q into %v" , item , v .Type ())
976
988
} else {
977
- d . error ( errPhase )
989
+ return errPhase
978
990
}
979
991
}
980
992
s := string (item )
@@ -983,14 +995,14 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool
983
995
if v .Kind () == reflect .String && v .Type () == numberType {
984
996
v .SetString (s )
985
997
if ! isValidNumber (s ) {
986
- d . error ( fmt .Errorf ("json: invalid number literal, trying to unmarshal %q into Number" , item ) )
998
+ return fmt .Errorf ("json: invalid number literal, trying to unmarshal %q into Number" , item )
987
999
}
988
1000
break
989
1001
}
990
1002
if fromQuoted {
991
- d . error ( fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal %q into %v" , item , v .Type () ))
1003
+ return fmt .Errorf ("json: invalid use of ,string struct tag, trying to unmarshal %q into %v" , item , v .Type ())
992
1004
} else {
993
- d . error ( & UnmarshalTypeError {Value : "number" , Type : v .Type (), Offset : int64 (d .readIndex ())})
1005
+ return & UnmarshalTypeError {Value : "number" , Type : v .Type (), Offset : int64 (d .readIndex ())}
994
1006
}
995
1007
case reflect .Interface :
996
1008
n , err := d .convertNumber (s )
@@ -1029,32 +1041,32 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool
1029
1041
v .SetFloat (n )
1030
1042
}
1031
1043
}
1044
+ return nil
1032
1045
}
1033
1046
1034
1047
// The xxxInterface routines build up a value to be stored
1035
1048
// in an empty interface. They are not strictly necessary,
1036
1049
// but they avoid the weight of reflection in this common case.
1037
1050
1038
1051
// valueInterface is like value but returns interface{}
1039
- func (d * decodeState ) valueInterface () (val interface {}) {
1052
+ func (d * decodeState ) valueInterface () (val interface {}, err error ) {
1040
1053
switch d .opcode {
1041
1054
default :
1042
- d .error (errPhase )
1043
- panic ("unreachable" )
1055
+ err = errPhase
1044
1056
case scanBeginArray :
1045
- val = d .arrayInterface ()
1057
+ val , err = d .arrayInterface ()
1046
1058
d .scanNext ()
1047
1059
case scanBeginObject :
1048
- val = d .objectInterface ()
1060
+ val , err = d .objectInterface ()
1049
1061
d .scanNext ()
1050
1062
case scanBeginLiteral :
1051
- val = d .literalInterface ()
1063
+ val , err = d .literalInterface ()
1052
1064
}
1053
1065
return
1054
1066
}
1055
1067
1056
1068
// arrayInterface is like array but returns []interface{}.
1057
- func (d * decodeState ) arrayInterface () []interface {} {
1069
+ func (d * decodeState ) arrayInterface () ( []interface {}, error ) {
1058
1070
var v = make ([]interface {}, 0 )
1059
1071
for {
1060
1072
// Look ahead for ] - can only happen on first iteration.
@@ -1063,7 +1075,11 @@ func (d *decodeState) arrayInterface() []interface{} {
1063
1075
break
1064
1076
}
1065
1077
1066
- v = append (v , d .valueInterface ())
1078
+ vi , err := d .valueInterface ()
1079
+ if err != nil {
1080
+ return nil , err
1081
+ }
1082
+ v = append (v , vi )
1067
1083
1068
1084
// Next token must be , or ].
1069
1085
if d .opcode == scanSkipSpace {
@@ -1073,14 +1089,14 @@ func (d *decodeState) arrayInterface() []interface{} {
1073
1089
break
1074
1090
}
1075
1091
if d .opcode != scanArrayValue {
1076
- d . error ( errPhase )
1092
+ return nil , errPhase
1077
1093
}
1078
1094
}
1079
- return v
1095
+ return v , nil
1080
1096
}
1081
1097
1082
1098
// objectInterface is like object but returns map[string]interface{}.
1083
- func (d * decodeState ) objectInterface () map [string ]interface {} {
1099
+ func (d * decodeState ) objectInterface () ( map [string ]interface {}, error ) {
1084
1100
m := make (map [string ]interface {})
1085
1101
for {
1086
1102
// Read opening " of string key or closing }.
@@ -1090,7 +1106,7 @@ func (d *decodeState) objectInterface() map[string]interface{} {
1090
1106
break
1091
1107
}
1092
1108
if d .opcode != scanBeginLiteral {
1093
- d . error ( errPhase )
1109
+ return nil , errPhase
1094
1110
}
1095
1111
1096
1112
// Read string key.
@@ -1099,20 +1115,24 @@ func (d *decodeState) objectInterface() map[string]interface{} {
1099
1115
item := d .data [start :d .readIndex ()]
1100
1116
key , ok := unquote (item )
1101
1117
if ! ok {
1102
- d . error ( errPhase )
1118
+ return nil , errPhase
1103
1119
}
1104
1120
1105
1121
// Read : before value.
1106
1122
if d .opcode == scanSkipSpace {
1107
1123
d .scanWhile (scanSkipSpace )
1108
1124
}
1109
1125
if d .opcode != scanObjectKey {
1110
- d . error ( errPhase )
1126
+ return nil , errPhase
1111
1127
}
1112
1128
d .scanWhile (scanSkipSpace )
1113
1129
1114
1130
// Read value.
1115
- m [key ] = d .valueInterface ()
1131
+ vi , err := d .valueInterface ()
1132
+ if err != nil {
1133
+ return nil , err
1134
+ }
1135
+ m [key ] = vi
1116
1136
1117
1137
// Next token must be , or }.
1118
1138
if d .opcode == scanSkipSpace {
@@ -1122,16 +1142,16 @@ func (d *decodeState) objectInterface() map[string]interface{} {
1122
1142
break
1123
1143
}
1124
1144
if d .opcode != scanObjectValue {
1125
- d . error ( errPhase )
1145
+ return nil , errPhase
1126
1146
}
1127
1147
}
1128
- return m
1148
+ return m , nil
1129
1149
}
1130
1150
1131
1151
// literalInterface consumes and returns a literal from d.data[d.off-1:] and
1132
1152
// it reads the following byte ahead. The first byte of the literal has been
1133
1153
// read already (that's how the caller knows it's a literal).
1134
- func (d * decodeState ) literalInterface () interface {} {
1154
+ func (d * decodeState ) literalInterface () ( interface {}, error ) {
1135
1155
// All bytes inside literal return scanContinue op code.
1136
1156
start := d .readIndex ()
1137
1157
d .scanWhile (scanContinue )
@@ -1140,27 +1160,27 @@ func (d *decodeState) literalInterface() interface{} {
1140
1160
1141
1161
switch c := item [0 ]; c {
1142
1162
case 'n' : // null
1143
- return nil
1163
+ return nil , nil
1144
1164
1145
1165
case 't' , 'f' : // true, false
1146
- return c == 't'
1166
+ return c == 't' , nil
1147
1167
1148
1168
case '"' : // string
1149
1169
s , ok := unquote (item )
1150
1170
if ! ok {
1151
- d . error ( errPhase )
1171
+ return nil , errPhase
1152
1172
}
1153
- return s
1173
+ return s , nil
1154
1174
1155
1175
default : // number
1156
1176
if c != '-' && (c < '0' || c > '9' ) {
1157
- d . error ( errPhase )
1177
+ return nil , errPhase
1158
1178
}
1159
1179
n , err := d .convertNumber (string (item ))
1160
1180
if err != nil {
1161
1181
d .saveError (err )
1162
1182
}
1163
- return n
1183
+ return n , nil
1164
1184
}
1165
1185
}
1166
1186
0 commit comments