Giter Club home page Giter Club logo

Comments (5)

binaryseed avatar binaryseed commented on August 26, 2024 1

Do you have to pattern match on the exception name? HTTPoison only has one exception type. This would also work...

{:error, %{reason: reason}} = response

I'll look into mirroring the Error struct but this ^ might fix it for you too

from elixir_agent.

brunozrk avatar brunozrk commented on August 26, 2024 1

summarizing, we have 3 options:

  • first
alias NewRelic.Instrumented.HTTPoison, as: NRHTTPoison

and then: NRHTTPoison.post(...)
  • second
case response do
   {:error, {reason: reason}} ->
           ...
   {:ok, {status_code: status, body: body}} ->
      case status do
            200 ->
              ...
            _ ->
              ...
      end
end
  • third
case response do
   {:error, %Elixir.HTTPoison.Error{reason: reason}} ->
           ...
   {:ok, %Elixir.HTTPoison.Response{status_code: status, body: body}} ->
      case status do
            200 ->
              ...
            _ ->
              ...
      end
end

I liked the third option, modifying the documentation should help, and I think mirroring the struts won't be necessary, what do you think?

from elixir_agent.

binaryseed avatar binaryseed commented on August 26, 2024 1

I'll update the docs to point folks to the 2nd and 3rd option based on their preferences.

Thanks for reporting this!

from elixir_agent.

binaryseed avatar binaryseed commented on August 26, 2024

Thanks we'll look into how to solve this

from elixir_agent.

binaryseed avatar binaryseed commented on August 26, 2024

One thing you can do is reference the top level module via Elixir. like this:

{:error, %Elixir.HTTPoison.Error{}} = HTTPoison.get("localhost:12345")

from elixir_agent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.