feat(search-backend-module-pg): improve error handling
Co-authored-by: Emma Indal <emma.indahl@gmail.com> Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
import { PluginDatabaseManager } from '@backstage/backend-common';
|
||||
import { SearchEngine } from '@backstage/plugin-search-backend-node';
|
||||
import { MissingIndexError } from '@backstage/plugin-search-backend-node';
|
||||
import {
|
||||
SearchQuery,
|
||||
IndexableResultSet,
|
||||
@@ -92,6 +93,12 @@ export class PgSearchEngine implements SearchEngine {
|
||||
this.databaseStore.query(tx, pgQuery),
|
||||
);
|
||||
|
||||
if (!rows.length) {
|
||||
throw new MissingIndexError(
|
||||
`Missing index for ${pgQuery.types}. This means there are no documents to search through.`,
|
||||
);
|
||||
}
|
||||
|
||||
// We requested one result more than the page size to know whether there is
|
||||
// another page.
|
||||
const { page } = decodePageCursor(query.pageCursor);
|
||||
|
||||
Reference in New Issue
Block a user