You've already forked pigallery2
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:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user