I have a lightning out application. I can easily catch backend errors and show it in the front-end via alerts or toasts. However, I wanted the host application to have a way to capture the error messages instead of showing it immediately. Another use case is, I don't want to use the alerts and toasts for showing the error, and instead i want the host's error display mechanism to display my errors instead. Is there a way to do this?
I don't have much experience on building Lightning Out apps, but going through the documentation, it seems you may not have a way to communicate between the components and your host application.
Referring to "Considerations for Using Lightning Out" on Lightning Out Considerations and Limitations, it discusses about this behavior (emphasis mine).
Another important consideration is more subtle. Many important actions your apps support are accomplished by firing various Lightning events. But events are sort of like that tree that falls in the forest. If no one’s listening, does it have an effect? In the case of many core Lightning events, the “listener” is the Lightning Experience or Salesforce app container,
one.app. And if
one.appisn’t there to handle the events, they indeed have no effect. Firing those events silently fails.