{@thread.name}

rellen__
2023-06-07

rellen__:

Hello.
In a previous project (which did not use Ash) we had a top-level Error module that had a defexception in it with all the typical error things, like codes, messages, and metadata. It also had some other functions to do things like, for example, report the error to various sinks (Logger and an APM platform). The idea was to replace returns like {:error, :some_error_code} or {:error, "some message"} with {:error, MyApp.Error.exception(...)} and let code that receives such errors decide it it wants to report, re-raise, etc etc.

With the existence of Ash.Error and all the helper code around it, I wonder if it makes sense to build an application’s top-level error off of Ash.Error instead of something custom? Even if those errors might not have anything to do with Ash? Is it the intention of Ash.Error to be used purely for errors coming from the framework, or is it a building block for user-defined errors?

Does anyone have any experience or thoughts on this? Thanks!

zachdaniel:

I think that’s a great idea 🙂 you can define your own ash errors using the same tools it uses under the hood, and standardize your errors that way.