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?

Showing Posts 1 to 5

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

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

ancatrusca
New episode with Tobias Pfeiffer (PragTob) covering Benchee’s design and the systematic mistakes that make most benchmarks misleading. P...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews