Okay then, so Error shall be handled only in funct...
# community-help
s
Okay then, so Error shall be handled only in functions where
typesenseClient
in this case is used? The
AggregateError
is I suppose something from node itself when I initialize Typesense on server start. It happened before I added
try{} catch{}
blocks in the function.
Copy code
private async initializeTypesense(): Promise<void> {
    try {
      if (!typesenseClient)
        return console.error({
          msg: "initializeTypesense: typesenseClient is not defined"
        });
      const collections = await typesenseClient?.collections().retrieve();
      const collectionsNames = collections?.map(
        (collection) => collection.name
      );
      if (!collectionsNames?.includes(typesenseNewsArticleSchema.name))
        await typesenseClient
          .collections()
          .create(typesenseNewsArticleSchema)
          .then((res) => console.log({ res }))
          .catch((err) =>
            console.log({
              msg: "Error while creating News Articles Typesense Schema",
              err
            })
          );
      
    } catch (error) {
      console.error({ msg: "initializeTypesense error" });
    }
  }