Skip to content

Commit

Permalink
Merge pull request #829 from axone-protocol/test/more_panic_err
Browse files Browse the repository at this point in the history
Test/more panic err
  • Loading branch information
ccamel authored Nov 27, 2024
2 parents d312020 + 6efba17 commit 191bbcb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions x/logic/keeper/grpc_query_ask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ func TestGRPCAsk(t *testing.T) {
maxVariables: 1000,
expectedError: "maximum number of variables reached: limit exceeded",
},
{
program: "l(L) :- length(L, 1). l(L) :- length(L, 1000).",
query: "l(L).",
limit: 2,
maxVariables: 1000,
expectedError: "maximum number of variables reached: limit exceeded",
},
{
program: "father(bob, 'élodie').",
query: "father(bob, X).",
Expand Down
5 changes: 3 additions & 2 deletions x/logic/util/prolog.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func QueryInterpreter(

var err engine.Exception
if errors.As(callErr, &err) {
if err, ok := isPanicError(err.Term(), env); ok {
if err, ok := isPanicError(err.Term()); ok {
return nil, errorsmod.Wrapf(types.LimitExceeded, "%s", err)
}
}
Expand Down Expand Up @@ -147,7 +147,8 @@ func isBound(v engine.ParsedVariable, env *engine.Env) bool {
}

// isPanicError returns the panic error message if the given term is a panic_error.
func isPanicError(term engine.Term, env *engine.Env) (string, bool) {
func isPanicError(term engine.Term) (string, bool) {
var env *engine.Env
if env, ok := env.Unify(term, errPanicError); ok {
return fmt.Sprintf("%s", env.Resolve(errMessageVar)), true
}
Expand Down

0 comments on commit 191bbcb

Please sign in to comment.