zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

wrapper_error.ex (1050B)


      1 defmodule Plug.Conn.WrapperError do
      2   @moduledoc """
      3   Wraps the connection in an error which is meant
      4   to be handled upper in the stack.
      5 
      6   Used by both `Plug.Debugger` and `Plug.ErrorHandler`.
      7   """
      8   defexception [:conn, :kind, :reason, :stack]
      9 
     10   def message(%{kind: kind, reason: reason, stack: stack}) do
     11     Exception.format_banner(kind, reason, stack)
     12   end
     13 
     14   @doc """
     15   Reraises an error or a wrapped one.
     16   """
     17   def reraise(%__MODULE__{stack: stack} = reason) do
     18     :erlang.raise(:error, reason, stack)
     19   end
     20 
     21   @deprecated "Use reraise/1 or reraise/4 instead"
     22   def reraise(conn, kind, reason) do
     23     reraise(conn, kind, reason, [])
     24   end
     25 
     26   def reraise(_conn, :error, %__MODULE__{stack: stack} = reason, _stack) do
     27     :erlang.raise(:error, reason, stack)
     28   end
     29 
     30   def reraise(conn, :error, reason, stack) do
     31     wrapper = %__MODULE__{conn: conn, kind: :error, reason: reason, stack: stack}
     32     :erlang.raise(:error, wrapper, stack)
     33   end
     34 
     35   def reraise(_conn, kind, reason, stack) do
     36     :erlang.raise(kind, reason, stack)
     37   end
     38 end