Handling errors with `catchTag` with program in ManagedRuntime

How can I catchTag when I am providing
ManagedRuntime
in the program runs?

export function getTranscript(
  file: any,
  keywords: string[] = [],
  language: string = 'en',
): Promise<TranscriptOutput | { error: string }> {
  return TranscribeRuntime.runPromise(
    program.pipe(
      Effect.provideService(Params, {
        language,
        keywords,
      }),
      Effect.provideService(MediaFile, file),
    )
  )
}


I tried this approach:
export function getTranscript(
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- deepgram sdk is not typed correctly
  file: any,
  keywords: string[] = [],
  language: string = 'en',
): Promise<TranscriptOutput | { error: string }> {
  return TranscribeRuntime.runPromise(
    program.pipe(
      Effect.provideService(Params, {
        language,
        keywords,
      }),
      Effect.provideService(MediaFile, file),
    ).pipe(
      Effect.catchTag(FetchError, () => ({ error: 'Failed to fetch transcript' })),
      Effect.catchTag(TranscribeError, () => ({ error: 'Failed to transcribe audio' })),
    )
  )
}


But it yells at me. 😦
Argument of type 'Effect<unknown, unknown, unknown>' is not assignable to parameter of type 'Effect<unknown, unknown, TranscribeApi>'.
  Type 'unknown' is not assignable to type 'TranscribeApi'.
Was this page helpful?