Let's say I have a parent element with router-outlet that routs to children-components. Like in the first 10 seconds of the fireship youtube tutorial: https://youtu.be/Np3ULAMqwNo
I have 10 different but similar child-components. The child component will do some API-requests. How can the parent-component display what went wrong in the API request? I don't want to write the same error-display code 10 times. Should I define some different error-codes and pass them up somehow?
Is it smart to use a router in that case even? What are the alternatives? Make requests in parent and send to child? But then how do I pass a complex response down the router-outlet?
Or can you create a generic "interface" component like in JAVA which has the error-handling and then specify the rest in the implementation of that component? If someone could point me to the right "construct" to do that, please. I researched a bit and found nothing.
I just want to prevent 10x repeated code to show the error in the children.
edit: I am also considering to use ngSwitchCase in parent to select the child-components instead of using routing. Is this maybe the best way to do it here? Binding lots of data between parent/child wouldn't be a problem here, you could probably communicate errors from the child component to the parent component. But how, with what "CONSTRUCT" would this be done the best?