Skip to content
Snippets Groups Projects
Commit 3bd974d3 authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Better error messages from unitfile.erb template.

Have the error messages that unitfile.erb can raise include reference
to the resource (type and title) causing the error, so users can find
where they made the error.
parent df8b5e43
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
# Copyright © 2021 Thomas Bellman, Linköping, Sweden # Copyright © 2021 Thomas Bellman, Linköping, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information. # Licensed under the GNU LGPL v3+; see the README file for more information.
-%> -%>
<% comment_lines = [@comment].flatten.join("\n").split("\n") <% resource_ref = "Systemd::%s[%s]" % [ @systemd_resource_type, @title, ]
comment_lines = [@comment].flatten.join("\n").split("\n")
if comment_lines.length() > 0 if comment_lines.length() > 0
comment_lines.each do |cline| comment_lines.each do |cline|
-%> -%>
...@@ -18,10 +19,11 @@ ...@@ -18,10 +19,11 @@
-%> -%>
<%= optname %>= <%= optname %>=
<% elsif @systemd_resource_type == 'Unit' <% elsif @systemd_resource_type == 'Unit'
raise(Puppet::ParseError, "Bad option name, ``#{optname}''") raise(Puppet::ParseError,
"#{resource_ref}: Bad option name, ``#{optname}''")
else else
raise(Puppet::ParseError, raise(Puppet::ParseError,
'Internal error: $systemd_resource_type bad value') "#{resource_ref}: Internal error: bad value for $systemd_resource_type, ``#{systemd_resource_type}''")
-%> -%>
<% end -%> <% end -%>
<% end -%> <% end -%>
...@@ -30,4 +32,4 @@ ...@@ -30,4 +32,4 @@
<% end -%> <% end -%>
<% end %> <% end %>
<% end -%> <% end -%>
# Managed by Puppet: Systemd::<%= @systemd_resource_type %>[<%= @title %>] # Managed by Puppet: <%= resource_ref %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment