Handling Either Left Error in Effect Typescript

hi everyone,

why my usage of Either stops the code from executing, I am trying to retrieve a key that currently doesn't exist and I want to return Either.left and then handle it, but I get an Uncaught Error

const getManifestId = Effect.gen(function* () {
  const { region, Name } = yield* SSMClientConfigContext;
  const ssmClient = new SSMClient({ region });
  const command = new GetParameterCommand({
    Name,
    WithDecryption: false,
  });
  const manifestId$ = yield* Effect.tryPromise({
    try: async () => {
      return Either.right((await ssmClient.send(command)).Parameter?.Value);
    },
    catch: (e) => Either.left(e),
  });
  return manifestId$;
});

const program = Effect.gen(function* () {
  const manifestId$ = yield* getManifestId;
  Either.mapBoth(
     manifestId$,
       {
        onRight: (manifestId) =>
          downloadVpkDir(manifest).pipe(
           Effect.unless(() => manifestId == latestManifestId),
          ),
        onLeft: (_) => downloadVpkDir(manifest),
       },
    );
})



error: Uncaught (in promise) (FiberFailure) Error: {
  "_id": "Either",
  "_tag": "Left",
  "left": {
    "name": "ParameterNotFound",
    "$fault": "client",
    "$metadata": {
      "httpStatusCode": 400,
      "requestId": "d28f8884-59ad-4694-b9cc-62ce28e3146c",
      "attempts": 1,
      "totalRetryDelay": 0
    },
    "__type": "ParameterNotFound",
    "message": "UnknownError"
  }
}
Was this page helpful?