Skip to content

Commit

Permalink
Better errors when build or pipeline can't be found
Browse files Browse the repository at this point in the history
  • Loading branch information
suprnova32 committed Mar 15, 2019
1 parent 0563103 commit 174d981
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/alloy_ci/web/controllers/build_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ defmodule AlloyCi.Web.BuildController do
|> put_flash(:info, "Project not found")
|> redirect(to: project_path(conn, :index))

nil ->
conn
|> put_flash(:info, "Build not found")
|> redirect(to: project_path(conn, :show, project_id))

build ->
conn
|> render("show.html", build: build, pipeline: build.pipeline, current_user: current_user)
Expand Down
14 changes: 12 additions & 2 deletions lib/alloy_ci/web/controllers/pipeline_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ defmodule AlloyCi.Web.PipelineController do
)
|> redirect(to: project_pipeline_path(conn, :show, project_id, pipeline))
else
_ ->
false ->
conn
|> put_flash(:info, "Project not found")
|> redirect(to: project_path(conn, :index))

nil ->
conn
|> put_flash(:info, "Pipeline not found")
|> redirect(to: project_path(conn, :show, project_id))
end
end

Expand All @@ -41,10 +46,15 @@ defmodule AlloyCi.Web.PipelineController do
builds = Builds.by_stage(pipeline)
render(conn, "show.html", builds: builds, pipeline: pipeline, current_user: current_user)
else
_ ->
false ->
conn
|> put_flash(:info, "Project not found")
|> redirect(to: project_path(conn, :index))

nil ->
conn
|> put_flash(:info, "Pipeline not found")
|> redirect(to: project_path(conn, :show, project_id))
end
end
end

0 comments on commit 174d981

Please sign in to comment.