mikmc commited on
Commit
288197c
·
verified ·
1 Parent(s): aa359e7

Update handlers/search-catalog.js

Browse files
Files changed (1) hide show
  1. handlers/search-catalog.js +6 -3
handlers/search-catalog.js CHANGED
@@ -3,21 +3,24 @@ module.exports = (dependencies) => {
3
 
4
  return async (args) => {
5
  try {
 
6
  validateContentType(args)
7
 
 
8
  const items = await searchCatalog({
9
  search: args.extra.search,
10
-
11
  genre: args.extra.genre,
12
-
13
  skip: args.extra.skip,
14
  })
15
 
 
16
  return {
17
  metas: items.map(toCatalog),
18
  }
19
  } catch (error) {
20
- return new Promise.resolve({ metas: [] })
 
 
21
  }
22
  }
23
  }
 
3
 
4
  return async (args) => {
5
  try {
6
+ // Validate the content type
7
  validateContentType(args)
8
 
9
+ // Perform the search using searchCatalog
10
  const items = await searchCatalog({
11
  search: args.extra.search,
 
12
  genre: args.extra.genre,
 
13
  skip: args.extra.skip,
14
  })
15
 
16
+ // Return the catalog in the required format
17
  return {
18
  metas: items.map(toCatalog),
19
  }
20
  } catch (error) {
21
+ // Handle any errors gracefully
22
+ console.error("Error in search-catalog handler:", error)
23
+ return { metas: [] }
24
  }
25
  }
26
  }