Hi everyone! Are you ok? I hope yes…
I’m working on a class whose its responsibility is calculate Brazilian taxes.
Its use is so and so like this:
invoice_product = InvoiceProduct.new(filtered_params)
operationkind = Operationkind.find(params[:operationkind_id])
recipient = Person.find(params[:recipient_id])
finder = Taxes::Premisefinder.new
render json: invoice_product, status: :created
It’s used in a controller to respond as json in a rest API. It’s not a ActiveRecord descendent class.
My doubt is: what is the best way to collect the possible errors generated from Taxes::Premisefinder?
Should I do Taxes::Premisefinder generates exceptions and catch them on the controller?
Should I use similar strategy of ActiveRecord using Errrors class?
In this case, what’s the Rails way to work?