From 8d5839724b4ad2ad32cd7dfda4952dc105937d42 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Sat, 16 Nov 2019 16:08:52 +0100 Subject: [PATCH] templates can now `raise` exceptions. --- src/gen-config.cr | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gen-config.cr b/src/gen-config.cr index 4185b7f..6ba2adf 100644 --- a/src/gen-config.cr +++ b/src/gen-config.cr @@ -116,10 +116,11 @@ class GenConfig::Context end end - #options["port"] = Crinja.function do - # service = (arguments.varargs[0]? || "").to_s.gsub /\//, ':' - # `get-port #{service}`.chomp - #end + options["raise"] = Crinja.function do + message = arguments.varargs.join "\n" + + raise Service::Exception.new "template error: #{message}" + end # FIXME: Move this to a separate binary? options["random_password"] = Crinja.function do