Skip to content

Commit 0194a34

Browse files
Merge pull request #20 from nakanoasaservice/feature/doc
doc: update JSDoc
2 parents adfd57e + 14573b9 commit 0194a34

File tree

3 files changed

+14
-121
lines changed

3 files changed

+14
-121
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.0",
2+
"version": "2.0.1",
33
"name": "@nakanoaas/tagged-error",
44
"license": "MIT",
55
"exports": "./index.ts",

index.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,25 @@ interface TaggedErrorOptions<Cause = undefined> {
2525
* @template Cause - The type of the cause data
2626
* @example
2727
* ```ts
28-
* const result = divideAndSquareRoot(10, 0);
28+
* const result = login("alice", "hunter2");
2929
*
30-
* if (result instanceof TaggedError) {
30+
* if (result instanceof Error) {
3131
* switch (result.tag) {
32-
* case "DIVIDE_BY_ZERO":
33-
* console.log("Cannot divide by zero");
32+
* case "USER_NOT_FOUND":
33+
* console.error(result.message);
3434
* break;
35-
* case "NEGATIVE_RESULT":
36-
* console.log(`Cannot square root ${result.cause.value}`);
35+
* case "ACCOUNT_LOCKED":
36+
* console.error(`Try again after ${result.cause.lockedUntil.toLocaleString()}`);
37+
* break;
38+
* case "WRONG_PASSWORD":
39+
* console.error(`${result.cause.attemptsRemaining} attempts remaining`);
3740
* break;
3841
* }
39-
* } else {
40-
* console.log("Result:", result); // result is typed as number
42+
* return;
4143
* }
44+
*
45+
* // result is typed as { userId: string; token: string }
46+
* console.log("Logged in:", result.userId);
4247
* ```
4348
*/
4449
export class TaggedError<Tag extends string, Cause = undefined> extends Error {

llms.txt

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)