Skip to content

Commit

Permalink
Do not lookup from errToCode map when error is of type slice.
Browse files Browse the repository at this point in the history
Closes #631.
  • Loading branch information
brocaar committed Oct 11, 2021
1 parent 651b572 commit e78b749
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/api/helpers/errors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package helpers

import (
"reflect"

"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -45,6 +47,13 @@ func ErrToRPCError(err error) error {
return cause
}

// Some error values (error returned by Otto) can not be hashed:
// https://github.com/brocaar/chirpstack-application-server/issues/631
k := reflect.TypeOf(cause).Kind()
if k == reflect.Slice {
return grpc.Errorf(codes.Unknown, cause.Error())
}

code, ok := errToCode[cause]
if !ok {
code = codes.Unknown
Expand Down

0 comments on commit e78b749

Please sign in to comment.