mnkhod

mnkhod

So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handling side of things on LiveView.

I understand there is 4 main category on the error class which are forbidden/invalid/framework/unknown. This is great but the problem is having to manage more than 1 errors. I understand the use case that errors propogating and coming as a list is great but what if i wanna show only 1 error since my frontend toast can only show 1 error message and having multiple error message would ruin it. Hence is there any configuration on ash action that allows me to say if any error occur then send that error and stop the whole action?

Having this would allow my invoking of code interface inside case statement be more lean since i can just pattern match on 1 error message to show multiple possible errrors inside put_flash.

Having to pattern match on Ash.Error.Invalid errors list with Enum.find and match function is making me go crazy.

Isnt this more lean tho? pls let me know if im being dumb

Showing Posts 1 to 1

zachdaniel

zachdaniel

Creator of Ash

I might need to see some code examples of how exactly you’re using it in your LV, but in general you can do things like this just fine:

defp get_one_error(%{errors: [error | _]}), do: error
defp get_one_error(error), do: error # fallback to using the class error in case you somehow just get one of those back

Ash itself doesn’t provide a way to just automatically stop on the first error and raise or return that, so whatever you do would need to be solved outside of the core calls.

— 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
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
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
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews