Skip to content

registry.RegisterTokenFilter should Return Error Instead of Panicking on Duplicate Registration #2125

@nanananakam

Description

@nanananakam

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions