Skip to content

Commit

Permalink
refactor: unify the error handling methods in the crypto package that…
Browse files Browse the repository at this point in the history
… are different from the project style

Signed-off-by: ChengenH <[email protected]>
  • Loading branch information
ChengenH committed Dec 13, 2024
1 parent 754b26e commit 6f59c80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions frontend/schema/internal/reflectwalk/reflectwalk.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func walk(v reflect.Value, w interface{}) (err error) {
if pointerV.Kind() == reflect.Interface {
if iw, ok := w.(InterfaceWalker); ok {
if err = iw.Interface(pointerV); err != nil {
if err == ErrSkipEntry {
if errors.Is(err, ErrSkipEntry) {
// Skip the rest of this entry but clear the error
return nil
}
Expand All @@ -124,7 +124,7 @@ func walk(v reflect.Value, w interface{}) (err error) {
if pointerV.Kind() == reflect.Ptr {
if pw, ok := w.(PointerValueWalker); ok {
if err = pw.Pointer(pointerV); err != nil {
if err == ErrSkipEntry {
if errors.Is(err, ErrSkipEntry) {
// Skip the rest of this entry but clear the error
return nil
}
Expand Down Expand Up @@ -271,7 +271,7 @@ func walkStruct(v reflect.Value, w interface{}) (err error) {
skip := false
if sw, ok := w.(StructWalker); ok {
err = sw.Struct(v)
if err == ErrSkipEntry {
if errors.Is(err, ErrSkipEntry) {
skip = true
err = nil
}
Expand All @@ -297,7 +297,7 @@ func walkStruct(v reflect.Value, w interface{}) (err error) {
err = sw.StructField(sf, f)

// SkipEntry just pretends this field doesn't even exist
if err == ErrSkipEntry {
if errors.Is(err, ErrSkipEntry) {
continue
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/schema/walk.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package schema

import (
"errors"
"fmt"
"reflect"
"strconv"
Expand All @@ -20,7 +21,7 @@ func Walk(circuit interface{}, tLeaf reflect.Type, handler LeafHandler) (count L
handler: handler,
}
err = reflectwalk.Walk(circuit, &w)
if err == reflectwalk.ErrSkipEntry {
if errors.Is(err, reflectwalk.ErrSkipEntry) {
err = nil
}
count.Public = w.nbPublic
Expand Down

0 comments on commit 6f59c80

Please sign in to comment.