siga

Sistema Interativo de GerĂȘncia de Atividades.
Log | Files | Refs | README | LICENSE

error_json.ex (737B)


      1 defmodule UsersWeb.ErrorJSON do
      2   @moduledoc """
      3   This module is invoked by your endpoint in case of errors on JSON requests.
      4 
      5   See config/config.exs.
      6   """
      7 
      8   # If you want to customize a particular status code,
      9   # you may add your own clauses, such as:
     10   #
     11   # def render("500.json", _assigns) do
     12   #   %{errors: %{detail: "Internal Server Error"}}
     13   # end
     14 
     15   @doc "Renders an error with a custom message."
     16   def detail(%{detail: detail}), do: %{errors: %{detail: detail}}
     17 
     18   # By default, Phoenix returns the status message from
     19   # the template name. For example, "404.json" becomes
     20   # "Not Found".
     21   def render(template, _assigns) do
     22     %{errors: %{detail: Phoenix.Controller.status_message_from_template(template)}}
     23   end
     24 end