ShadowKnightMK4 / OdinSearch

Search thru local computer files and feed matching output to a class that consumes it.
MIT License
1 stars 0 forks source link

Before spawning the worker threads, attempt to create the regex input - especially if we're passing it as is (RawRegEx) #30

Closed ShadowKnightMK4 closed 3 months ago

ShadowKnightMK4 commented 4 months ago

see title,

if the creation of a regex class with the input fails, don't spawn the threads, throw an exception to alert the user.

ShadowKnightMK4 commented 3 months ago

In theory This one done.

The regex conversion code is housed in an internal routine WorkerThreadInitRegEx() that loops thru the regex stuff in SearchTarget to make instances of RegEx class to check for them. Should the RegEx class fail to initialize and throw an exception, it appears to propagate ok up to being an example seen in OdinSearch.Search().

Unit Tests TestNULL_BackRegEx_OnInput_bad_pattern_SafetyOn() and TestNULL_BackRegEx_OnInput_bad_pattern_SafetyOff() both are modified to catch a RegexParseException().

Changes: WorkerThreadInit() - contains the old init code that originally ran in the WorkerThreadProc(). Note that it is still programmed to call this in the event that it receives an empty list as a fallback but normal execution shouldn't have that happen.

Internal class WorkerThreadArgs now has a new entry, List which will receive the initialized RegEx stuff to compare strings. WorkerThread does assume once itself is running, that list can't change.

Please keep in mind if you depend on routines/classes marked as internal. The various classes in OdinSearch marked internal are subject to change from release to release and update.