Catch errors and print stack trace