Updated main activity to handle and print exceptions.