main: Log uncaught exceptions

(cherry picked from commit 027b7a53fe9212853062da352c464c4277ade510)