≡

Invalid regex results in console error

Invalid regex results in console error

bg7bg7 Posts: 159Questions: 24Answers: 0

If you enable regex for search, every invalid regex string bubbles up to the browser console as an error. You can see it in this example:

https://live.datatables.net/fubagako/1/edit

Is there a reason this exception is uncaught? If you're typing in a regex string the console ends up filled with every keystroke if the regex isn't correct yet. A good example is typing in an open paren, then the contents of that open/closed paren and then closing it. I searched and could only find one reference to this from years ago:

https://datatables.net/forums/discussion/comment/178883/#Comment_178883

I understand there's an edge case for people who want to trigger behavior when the regex isn't correct. Wouldn't it be better if there were an event you could listen for when the regex is invalid instead of having it all bubble up to the console?

Thanks.

Ben

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 66,179Questions: 1Answers: 11,039 Site admin
    Answer ✓

    HI Ben,

    Is there a reason this exception is uncaught?

    I never thought to catch it :). I've added that now, but just with a log message about the error rather than an event. That is something I could look at adding if there is need for it.

    Allan

  • bg7bg7 Posts: 159Questions: 24Answers: 0

    Allan,

    Fair enough. If you decide at some point to make it an event that's cool but I'll definitely take a console log over an exception in the console.

    Thanks.

    Ben

Sign In or Register to comment.