ngw

ngw

Hi, I’m using Tesla for a fun project, and I noticed it “explodes” instead of, for example, returning an {:error, something} tuple in case something goes wrong.

iex(2)> Tesla.get("http://foobar.baz")
** (Tesla.Error) adapter error: :econnrefused
    lib/tesla/middleware/core.ex:10: Tesla.Middleware.Normalize.normalize/1

How to handle this? Should I use a try block? What if the Tesla call is inside an Enum.map over many urls? Is there an idiomatic way to handle this?

First 5 of 5 Posts Switch mode

OvermindDL1

OvermindDL1

Try is basically what you would need for this unless it exposes another API (if get throws it really should be get!, bleh…

NobbZ

NobbZ

The documentation doesn’t even mention to throw or raise, and as far as I was able to scan the docs, there is no tupled version of the functions available.

In my opinion the API should be reworked drastically! Catching is expensive, and not everyone wants to just crash…

ngw

ngw OP

Yeah I guess it’s a bit odd, might be the case to switch to another more “educate” library like HTTPipe, because honestly it doesn’t seem such an incredible occurrence to try to GET a url that doesn’t exist for an HTTP library :slight_smile:

vmoravec

vmoravec

Before switching to any other library I would recommend to raise an issue on Tesla github repo and ask the maintainer of the library for improvement or for reasoning why it was designed that way: GitHub - elixir-tesla/tesla: The flexible HTTP client library for Elixir, with support for middleware and multiple adapters. · GitHub

teamon

teamon

This has been brought up in the past and just now - please take a look at More conventional output · Issue #64 · elixir-tesla/tesla · GitHub and Return error tuple instead of raising errors by gdub01 · Pull Request #81 · elixir-tesla/tesla · GitHub
As you can see, it is very easy to change this behaviour to whatever suits you best - tesla was designed to be extensible as much as possible. I’m happy to continue the discussion in tesla’ github issues.

I should’ve probably ignore this, but as a active member of elixir community I feel obligated to do my best to make it a nice and helpful place for everyone and stand up to undesired behaviour.

I know having issues with 3rd party libraries can be frustrating. But please remember that most of the time these libraries are made by people for free, with their own free time. Pointing that something “should” be done this way or another is not a good way to start a discussion. Not to mention the rest of pointless, ranting comments here. This is the perfect example of making a hostile community.

Thank you @vmoravec for a reasonable approach to this issue. That’s how we can get nice things.

12
Post #5
— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement