File tree Expand file tree Collapse file tree 2 files changed +8
-16
lines changed Expand file tree Collapse file tree 2 files changed +8
-16
lines changed Original file line number Diff line number Diff line change @@ -39,21 +39,17 @@ type Assigner interface {
3939// with the updated value pertinent to that path.
4040//
4141func Assign (dst interface {}, ptr JSONPointer , value interface {}) error {
42- if err := ptr .Validate (); err != nil {
43- return err
44- }
4542 if value == nil {
4643 return Delete (dst , ptr )
4744 }
4845 dv := reflect .ValueOf (dst )
4946 s := newState (ptr , Assigning )
5047 defer s .Release ()
48+ if err := ptr .Validate (); err != nil {
49+ return newError (err , * s , dv .Type ())
50+ }
5151 if dv .Kind () != reflect .Ptr || dv .IsNil () {
52- return & ptrError {
53- state : * s ,
54- err : ErrNonPointer ,
55- typ : dv .Type (),
56- }
52+ return newError (ErrNonPointer , * s , dv .Type ())
5753 }
5854 cpy := dv
5955 dv = dv .Elem ()
Original file line number Diff line number Diff line change @@ -26,18 +26,14 @@ type Deleter interface {
2626// If any part of the path is unreachable, the Delete function is
2727// considered a success as the value is not present to delete.
2828func Delete (src interface {}, ptr JSONPointer ) error {
29- if err := ptr .Validate (); err != nil {
30- return err
31- }
3229 dv := reflect .ValueOf (src )
3330 s := newState (ptr , Deleting )
3431 defer s .Release ()
32+ if err := ptr .Validate (); err != nil {
33+ return newError (err , * s , dv .Type ())
34+ }
3535 if dv .Kind () != reflect .Ptr || dv .IsNil () {
36- return & ptrError {
37- state : * s ,
38- err : ErrNonPointer ,
39- typ : dv .Type (),
40- }
36+ return newError (ErrNonPointer , * s , dv .Type ())
4137 }
4238 cpy := dv
4339 dv = dv .Elem ()
You can’t perform that action at this time.
0 commit comments