Error handling for invalid regexes