nicer search error message

This commit is contained in:
byte[] 2019-11-15 10:40:10 -05:00
parent 4cfaf47573
commit b18e17a179
2 changed files with 12 additions and 2 deletions

View file

@ -24,10 +24,11 @@ defmodule PhilomenaWeb.SearchController do
conn
|> render("index.html", images: images, search_query: params["q"])
else
{:error, _msg} ->
{:error, msg} ->
conn
|> render("index.html",
images: [],
error: msg,
search_query: params["q"]
)
end

View file

@ -1 +1,10 @@
= cond do
- Enum.any?(@images) ->
= render PhilomenaWeb.ImageView, "index.html", conn: @conn, images: @images, route: fn p -> Routes.search_path(@conn, :index, p) end, params: [q: @search_query]
- assigns[:error] ->
p
' Oops, there was an error evaluating your query:
pre = assigns[:error]
- true ->
p
' No images found!