Catch certain errors with regex