Error tracking on device - RC0

I would like to know when something goes wrong with app on user’s device. My idea is catch all errors and send them through API. How can I catch errors which are normally printed to the console? Or is there a better way? Thanks!