1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2026-05-16 09:21:12 +02:00

Improve search error handling

This commit is contained in:
Patrik J. Braun
2025-12-29 17:14:21 +01:00
parent 5932b57e26
commit dc8b08fafc
+14 -1
View File
@@ -22,7 +22,7 @@ import {
SearchQueryTypes,
SomeOfSearchQuery,
TextSearch,
TextSearchQueryMatchTypes,
TextSearchQueryMatchTypes, TextSearchQueryTypes,
} from '../../../common/entities/SearchQueryDTO';
import {GalleryManager} from './GalleryManager';
import {ObjectManagers} from '../ObjectManagers';
@@ -887,6 +887,19 @@ export class SearchManager {
throw new Error('Some of not supported');
}
if(!TextSearchQueryTypes.includes(query.type)){
throw new Error(
`Invalid search query: Unknown query type: ${SearchQueryTypes[query.type]}(type: ${query.type})`
);
}
if (typeof (query as TextSearch).value === 'undefined') {
throw new Error(
`Invalid search query: ${SearchQueryTypes[query.type]}(type: ${query.type}) query should contain 'value' property. Query got: ${JSON.stringify(query)}`
);
}
return new Brackets((q: WhereExpression) => {
const createMatchString = (str: string): string => {
if (