From 9273a1d01dd08b313916dbf4eafc806ec993debb Mon Sep 17 00:00:00 2001 From: Pedro Fontana Date: Tue, 19 Sep 2023 14:03:55 -0300 Subject: [PATCH] Handle cast error --- pkg/hints/usort_hints.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/hints/usort_hints.go b/pkg/hints/usort_hints.go index 3d0a5d75..ba1d0c67 100644 --- a/pkg/hints/usort_hints.go +++ b/pkg/hints/usort_hints.go @@ -3,6 +3,7 @@ package hints import ( "github.com/lambdaclass/cairo-vm.go/pkg/lambdaworks" "github.com/lambdaclass/cairo-vm.go/pkg/types" + "github.com/pkg/errors" ) // Implements hint: @@ -10,7 +11,11 @@ import ( func usort_enter_scope(executionScopes *types.ExecutionScopes) error { usort_max_size, err := executionScopes.Get("usort_max_size") - usort_max_size_felt := usort_max_size.(lambdaworks.Felt) + usort_max_size_felt, cast_ok := usort_max_size.(lambdaworks.Felt) + + if !cast_ok { + return errors.New("Error casting usort_max_size into a Felt") + } if err != nil { return err