From 6a5e5b8f7a8d29d2688413cd3990df739b6b2de6 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 20 Dec 2022 21:40:47 -0700 Subject: [PATCH] Catch errors while evaluating node labels --- src/spectator/dsl/examples.cr | 6 +++++- src/spectator/dsl/groups.cr | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/spectator/dsl/examples.cr b/src/spectator/dsl/examples.cr index 4524001..8a08116 100644 --- a/src/spectator/dsl/examples.cr +++ b/src/spectator/dsl/examples.cr @@ -125,7 +125,11 @@ module Spectator::DSL {% if what.is_a?(StringLiteral) || what.is_a?(NilLiteral) %} {{what}} {% elsif what.is_a?(StringInterpolation) %} - {{@type.name}}.new.eval { {{what}} } + {{@type.name}}.new.eval do + {{what}} + rescue e + "" + end {% else %} {{what.stringify}} {% end %} diff --git a/src/spectator/dsl/groups.cr b/src/spectator/dsl/groups.cr index f595791..da06906 100644 --- a/src/spectator/dsl/groups.cr +++ b/src/spectator/dsl/groups.cr @@ -137,7 +137,11 @@ module Spectator::DSL what.is_a?(NilLiteral) %} {{what}} {% elsif what.is_a?(StringInterpolation) %} - {{@type.name}}.new.eval { {{what}} } + {{@type.name}}.new.eval do + {{what}} + rescue e + "" + end {% else %} {{what.stringify}} {% end %}