Skip to content

Commit

Permalink
Improve error message for missing templates (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
axelson authored Jul 10, 2023
1 parent d6098a7 commit b734d94
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/phoenix/template.ex
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,15 @@ defmodule Phoenix.Template do
if function_exported?(module, :render, 2) do
module.render(template <> "." <> format, assigns)
else
raise ArgumentError, "no \"#{template}\" #{format} template defined for #{inspect(module)}"
reason =
if Code.ensure_loaded?(module) do
" (the module is defined but does define #{template}/1 nor render/2)"
else
" (the module does not exist)"
end

raise ArgumentError,
"no \"#{template}\" #{format} template defined for #{inspect(module)} #{reason}"
end
end

Expand Down

0 comments on commit b734d94

Please sign in to comment.