Trying to catch errors but failing?