From bbaa8816b8cc6faa9b28b92730eed53237b84ac6 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 25 Mar 2022 23:54:44 -0600 Subject: [PATCH] Weird segfault when inspecting value type is back. Working around with a crude rescue block. --- src/spectator/mocks/stubbable.cr | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/spectator/mocks/stubbable.cr b/src/spectator/mocks/stubbable.cr index 6d6d860..8e531b4 100644 --- a/src/spectator/mocks/stubbable.cr +++ b/src/spectator/mocks/stubbable.cr @@ -292,7 +292,12 @@ module Spectator nil {% else %} # The stubbed value was something else entirely and cannot be cast to the return type. - raise TypeCastError.new("#{_spectator_stubbed_name} received message #{ {{call}} } and is attempting to return a `#{%value.class}`, but returned type must be `#{ {{type}} }`.") + %type = begin + %value.class.to_s + rescue + "" + end + raise TypeCastError.new("#{_spectator_stubbed_name} received message #{ {{call}} } and is attempting to return a `#{%type}`, but returned type must be `#{ {{type}} }`.") {% end %} end end