You're probably underusing middleware for HTTP response handling
The article discusses the importance of using middleware for HTTP response handling in Elixir applications. It highlights that placing response handling code directly in function bodies can lead to missed errors and inadequate observability. By utilizing middleware, developers can enhance error tracking and improve the reliability of their applications.
- ▪Middleware can fail the request itself, improving telemetry and observability.
- ▪Real APIs often return unexpected or malformed data, which can lead to failures if not handled properly.
- ▪The article critiques common patterns in response handling that may overlook critical errors.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 100150) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Artur Plysiuk Posted on May 17 You're probably underusing middleware for HTTP response handling #elixir #tesla #api #observability When you wrap an external API in Elixir (a module called Acme for whatever the upstream service is), most of what Acme.fetch_user/1 does is response handling: check that the response means what you expect, pull data out of it, translate failures into something the rest of your application can use.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).