sqlite: error if sqlite isn't enabled but search() is called

When we assert that something can't possibly happen, we better
error out rather than jugging on with no error ;)
This commit is contained in:
Reto Brunner 2022-08-27 11:03:49 +02:00 committed by Reto Brunner
parent 0fa203569a
commit cebc6d069f

View File

@ -213,10 +213,12 @@ class SqliteMessageStorage implements ISqliteMessageStorage {
}) as Promise<Message[]>; }) as Promise<Message[]>;
} }
search(query: SearchQuery): Promise<SearchResponse | []> { search(query: SearchQuery): Promise<SearchResponse> {
if (!this.isEnabled) { if (!this.isEnabled) {
// this should never be hit as messageProvider is checked in client.search() // this should never be hit as messageProvider is checked in client.search()
return Promise.resolve([]); return Promise.reject(
"search called but sqlite provider not enabled. This is a programming error"
);
} }
// Using the '@' character to escape '%' and '_' in patterns. // Using the '@' character to escape '%' and '_' in patterns.