Improves error handling in anafora.regex