Skip to content

Commit d2436f2

Browse files
committed
feat: handle MaxVariables error limit exceeded
1 parent 7c51be8 commit d2436f2

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

x/logic/interpreter/registry.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package interpreter
22

33
import (
44
"fmt"
5-
orderedmap "github.com/wk8/go-ordered-map/v2"
65
"strconv"
76
"strings"
87

8+
orderedmap "github.com/wk8/go-ordered-map/v2"
9+
910
"github.com/ichiban/prolog"
10-
engine "github.com/ichiban/prolog/engine"
11+
"github.com/ichiban/prolog/engine"
1112

1213
"github.com/axone-protocol/axoned/v8/x/logic/predicate"
1314
)

x/logic/prolog/tuple.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import "github.com/ichiban/prolog/engine"
44

55
// Tuple is a predicate which unifies the given term with a tuple of the given arity.
66
func Tuple(args ...engine.Term) engine.Term {
7-
return engine.Atom(0).Apply(args...)
7+
return engine.Atom("").Apply(args...)
88
}

x/logic/util/prolog.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,18 @@ func QueryInterpreter(
5454
// error is not part of the look-ahead and should be included in the solutions
5555
sdkCtx := sdk.UnwrapSDKContext(ctx)
5656

57+
var panicErr engine.PanicError
5758
switch {
5859
case errors.Is(callErr, types.LimitExceeded):
59-
return nil, callErr
60+
return nil, err
61+
case errors.As(callErr, &panicErr) && errors.Is(panicErr.OriginErr, engine.ErrMaxVariables):
62+
return nil, errorsmod.Wrapf(types.LimitExceeded, panicErr.OriginErr.Error())
6063
case sdkCtx.GasMeter().IsOutOfGas():
6164
return nil, errorsmod.Wrapf(
6265
types.LimitExceeded, "out of gas: %s <%s> (%d/%d)",
6366
types.ModuleName, callErr.Error(), sdkCtx.GasMeter().GasConsumed(), sdkCtx.GasMeter().Limit())
64-
default:
65-
results = append(results, types.Result{Error: callErr.Error()})
6667
}
68+
results = append(results, types.Result{Error: callErr.Error()})
6769
} else {
6870
// error is part of the look-ahead, so let's consider that there's one more solution
6971
count = count.Incr()

0 commit comments

Comments
 (0)