Error display for user: Service or Component?


#1

Hi,

I want to be able to display an alert to the user interface when there is an error.

I decided to create an errorService and that one had a function that accepted a title and message to show an alert. I got an error (I need to get back my old code), but in summary, it did not like that I use the NavController to display my alert inside my service. Is it because my main page had a reference to a NavController and my service had another one?

Anyway, for now, I decided to just call an internal function from my page class to display that alert. Doing that, it is not very “professional” knowing that most of my pages will have the same/similar code.

How would you handle the errors and display them to the user by having a single location that will handle that?

Thanks in advance