patzly / grocy-android

ERP beyond your fridge, now on your phone – An awesome companion app for grocy
https://patrickzedler.com/grocy/
GNU General Public License v3.0
829 stars 80 forks source link

Show error message from backend (in case of consuming recipe if ingredients with disabled stock fulfillment checking) #866

Open rugk opened 2 months ago

rugk commented 2 months ago

STR

See https://github.com/grocy/grocy/issues/2533 TL;DR: Make a recipe with an ingredient with "stock fulfillment checking" disabled. Not have it in stock.

Then try to consume the recipe from the app.

What happens

https://github.com/patzly/grocy-android/assets/11966684/69f2b06a-94f3-4da4-abdf-3df5ae31019a

Just shows a very generic error:

Netzwerkfehler

com.android.volley.ClientError
    at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:257)
    at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:62)
    at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:6)

A server error is shown, but no details. Grocy web, shows this instead:

"{\"error_message\":\"Amount to be consumed cannot be > current stock amount (if supplied, at the desired location)\"}"

What should happen

You may at least pass that error message to the user?

dominiczedler commented 2 months ago

Thanks for the suggestion, I will look whether the API does return the error too.

rugk commented 2 months ago

Thanks yeah, maybe you can also show the stock amount even for "stock fulfillment checking"-disabled ingredients to prevent this error from occurring initially. (Especially, as – as indicated upstream – the error message, even if displayed, does not mention the bad ingredient, which can lead to painful debugging of your recipe :sweat_smile:) Everything else would AFAIK need server support/changes in the general handling, as suggested in https://github.com/grocy/grocy/issues/2533.