From 708dc012953f555e0434b366cb004977d0821979 Mon Sep 17 00:00:00 2001 From: neodarz Date: Fri, 17 Feb 2017 11:33:27 +0100 Subject: Adding error handling --- web/views/error_view.ex | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'web/views/error_view.ex') diff --git a/web/views/error_view.ex b/web/views/error_view.ex index e47ebee..5906829 100644 --- a/web/views/error_view.ex +++ b/web/views/error_view.ex @@ -14,4 +14,15 @@ defmodule TheTranscriberBackend.ErrorView do def template_not_found(_template, assigns) do render "500.html", assigns end + + def render("404.json", %{reason: reason}) do + message = case reason do + %Phoenix.Router.NoRouteError{} -> "Route not found" + %Ecto.NoResultsError{} -> "File not found in database !" + _ -> "Uncaught exception" + end + # ContactService.ResponseHelper.error(message) + %{error: message} +end + end -- cgit v1.2.1