Skip to content

Missing pretty printing elixir expression for remote Exception #42

@simonprev

Description

@simonprev

Thanks for the library, I really like the initiative! gradient has already identified many typing bugs in my app 😄

My Phoenix endpoint file raises a runtime error when executing mix gradient

lib/my_app_web/endpoint.ex: ** (FunctionClauseError) no function clause matching in Gradient.ElixirExpr.pp_expr/1    
                                               
    The following arguments were given to Gradient.ElixirExpr.pp_expr/1:                       
                                               
        # 1                                    
        {:remote, 1, {:atom, 1, Exception}, {:atom, 1, :normalize}}                            
                                               
    Attempted function clauses (showing 10 out of 32):                                         
                                               
        def pp_expr(exprs) when is_list(exprs)
        def pp_expr({:atom, _, val}) when val === nil or val === true or val === false         
        def pp_expr({:atom, _, val})
        def pp_expr({:char, _, l})
        def pp_expr({:float, _, l})
        def pp_expr({:integer, _, l})
        def pp_expr({:string, _, charlist})
        def pp_expr({:cons, _, _, _} = cons)
        def pp_expr({:fun, _, {:function, name, arity}})                                       
        def pp_expr({:fun, _, {:function, {:atom, _, module}, {:atom, _, name}, arity}})       
        ...                                    
        (22 clauses not shown)
                                               
    (gradient 0.1.0) lib/gradient/elixir_expr.ex:25: Gradient.ElixirExpr.pp_expr/1

The culprit seem to be Sentry.PlugCapture that injects a some codes:

      def call(conn, opts) do
        try do
          super(conn, opts)
        rescue
          e in Plug.Conn.WrapperError ->
            exception = Exception.normalize(:error, e.reason, e.stack)
            _ = Sentry.capture_exception(exception, stacktrace: e.stack, event_source: :plug)
            Plug.Conn.WrapperError.reraise(e)

          e ->
            _ = Sentry.capture_exception(e, stacktrace: __STACKTRACE__, event_source: :plug)
            :erlang.raise(:error, e, __STACKTRACE__)
        catch
          kind, reason ->
            message = "Uncaught #{kind} - #{inspect(reason)}"
            stack = __STACKTRACE__
            _ = Sentry.capture_message(message, stacktrace: stack, event_source: :plug)
            :erlang.raise(kind, reason, stack)
        end
      end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions