This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: feat: added Effect.tapErrorTag
- Loading branch information
1 parent
49f1405
commit 8999cf4
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@effect/io": patch | ||
--- | ||
|
||
added Effect.tapErrorTag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { pipe } from "@effect/data/Function" | ||
import * as Effect from "@effect/io/Effect" | ||
import { describe, expect, it } from "vitest" | ||
|
||
class TestError1 { | ||
readonly _tag = "TestError1" | ||
constructor() {} | ||
} | ||
|
||
class TestError2 { | ||
readonly _tag = "TestError2" | ||
constructor() {} | ||
} | ||
|
||
describe.concurrent("Effect", () => { | ||
it("tapErrorTag", async () => { | ||
let val = 0 | ||
|
||
await pipe( | ||
Effect.fail<TestError1 | TestError2>(new TestError2()), | ||
Effect.tapErrorTag("TestError1", () => Effect.sync(() => val += 1)), // not called | ||
Effect.tapErrorTag("TestError2", () => Effect.sync(() => val += 1)), // called | ||
Effect.catchAll(() => Effect.succeed("")), | ||
Effect.runPromise | ||
) | ||
|
||
expect(val).toBe(1) | ||
}) | ||
}) |