Effect CommunityEC
Effect Community2mo ago
4 replies
LiquiFruit

Issue with Pipe Usage in Effect Chain

What am I doing wrong here?
(alias) getRecordsByFilter({...}): Effect.Effect<object[], KnackError, never>

        // doesnt work     
        const checklistBuildings = yield* pipe(
                getRecordsByFilters({...})
        Schema.decodeUnknown(Schema.Array(ChecklistBuildingFromKnack))(
            checklistBuildingsResult,
        ),
        Effect.catchTag(
            "ParseError",
            (e) =>
                new KnackError({
                    message: "...",
                }),
        ),
    )

        // works
    const result = yield* getRecordsByFilter({...})
    const checklistBuildings = yield* pipe(
        Schema.decodeUnknown(Schema.Array(ChecklistBuildingFromKnack))(
            checklistBuildingsResult,
        ),
        Effect.catchTag(
            "ParseError",
            (e) =>
                new KnackError({
                    message:
                        "Failed to transform a checklist building from knack to domain: " +
                        "\n" +
                        e.message,
                }),
        ),
    )


KnackError: ...: 
Expected ..., actual {
  "_id": "Effect",
  "_op": "Commit"
}
Was this page helpful?