Currently, the registry.RegisterTokenFilter function in bleve v2 triggers a panic if a token filter with the same name is already registered. This behavior makes it difficult to handle duplicate registration gracefully and requires using a recover statement to prevent the application from crashing.
For better error handling and code maintainability, I propose that RegisterTokenFilter be changed to return an error (e.g., analysis.ErrTokenFilterAlreadyRegistered) instead of panicking when a duplicate registration is detected. This change would allow developers to easily check if a token filter has already been registered and react accordingly, without resorting to using recover.
Currently, the registry.RegisterTokenFilter function in bleve v2 triggers a panic if a token filter with the same name is already registered. This behavior makes it difficult to handle duplicate registration gracefully and requires using a recover statement to prevent the application from crashing.
For better error handling and code maintainability, I propose that RegisterTokenFilter be changed to return an error (e.g., analysis.ErrTokenFilterAlreadyRegistered) instead of panicking when a duplicate registration is detected. This change would allow developers to easily check if a token filter has already been registered and react accordingly, without resorting to using recover.