Get error handling working correctly