Skip to content

Commit 5ae72c5

Browse files
committed
update docs again
1 parent 03aef33 commit 5ae72c5

File tree

6 files changed

+126
-121
lines changed

6 files changed

+126
-121
lines changed

docs/content/contents.mdx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,29 @@ course:
1515
filePath: /getting-started/mightFail.mdx
1616
slug: /might-fail
1717
type: documentation
18+
- title: "`makeMightFail`"
19+
filePath: /getting-started/makeMightFail.mdx
20+
slug: /make-might-fail
21+
type: documentation
1822
- title: "`mightFailSync`"
1923
filePath: /getting-started/mightFailSync.mdx
2024
slug: /might-fail-sync
2125
type: documentation
22-
- title: "Static Methods"
23-
filePath: /getting-started/static-methods.mdx
24-
slug: /static-methods
26+
- title: "`makeMightFailSync`"
27+
filePath: /getting-started/makeMightFailSync.mdx
28+
slug: /make-might-fail-sync
2529
type: documentation
2630
- title: "Either Type"
2731
filePath: /getting-started/either.mdx
2832
slug: /either
2933
type: documentation
3034
- title: "More Things"
31-
slug: /more-things
32-
filePath: /more-things/more-things.mdx
3335
icon: "rocket"
3436
pages:
37+
- title: "Static Methods"
38+
filePath: /more-things/static-methods.mdx
39+
slug: /static-methods
40+
type: documentation
3541
- title: "`might-and-fail`"
3642
filePath: /more-things/might-and-fail.mdx
3743
slug: /might-and-fail
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## `makeMightFail`
2+
3+
You also have the option to make your own `mightFail` wrapper function. Pass in any async function to `makeMightFail` and it will return a `mightFail` wrapper function for you to use.
4+
5+
<Note>
6+
This is useful in some use cases, but most of the time you should just use `mightFail` directly.
7+
</Note>
8+
9+
<Tabs>
10+
<Tab name="tuple">
11+
```ts
12+
const get = makeMightFail(axios.get);
13+
const [ error, result ] = await get("/posts");
14+
15+
if (error) {
16+
// handle error
17+
return;
18+
}
19+
20+
const posts = result.data
21+
posts.map((post) => console.log(post.title));
22+
```
23+
</Tab>
24+
<Tab name="object">
25+
```ts
26+
const get = makeMightFail(axios.get);
27+
const { error, result } = await get("/posts");
28+
29+
if (error) {
30+
// handle error
31+
return;
32+
}
33+
34+
const posts = result.data
35+
posts.map((post) => console.log(post.title));
36+
```
37+
</Tab>
38+
<Tab name="go">
39+
```ts
40+
const get = makeMightFail(axios.get);
41+
const [ result, error ] = await get("/posts");
42+
43+
if (error) {
44+
// handle error
45+
return;
46+
}
47+
48+
const posts = result.data
49+
posts.map((post) => console.log(post.title));
50+
```
51+
</Tab>
52+
</Tabs>
53+
54+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
## `makeMightFailSync`
2+
3+
You also have the option to make your own `mightFailSync` wrapper function. Pass in any sync function to `makeMightFailSync` and it will return a `mightFailSync` wrapper function for you to use.
4+
5+
<Note>
6+
This is useful in some use cases, but most of the time you should just use `mightFailSync` directly.
7+
</Note>
8+
9+
<Tabs>
10+
<Tab name="tuple">
11+
```ts
12+
function parseJSON(jsonString: string) {
13+
return JSON.parse(jsonString); // This might throw
14+
}
15+
const mightParseJSON = makeMightFailSync(parseJSON);
16+
17+
const [error, result] = mightParseJSON("");
18+
19+
if (error) {
20+
console.error("Parsing failed:", error);
21+
return;
22+
}
23+
24+
console.log("Parsed object:", result);
25+
```
26+
</Tab>
27+
<Tab name="object">
28+
```ts
29+
function parseJSON(jsonString: string) {
30+
return JSON.parse(jsonString); // This might throw
31+
}
32+
const mightParseJSON = makeMightFailSync(parseJSON);
33+
34+
const { error, result } = mightParseJSON("");
35+
36+
if (error) {
37+
console.error("Parsing failed:", error);
38+
return;
39+
}
40+
41+
console.log("Parsed object:", result);
42+
```
43+
</Tab>
44+
<Tab name="go">
45+
```ts
46+
function parseJSON(jsonString: string) {
47+
return JSON.parse(jsonString); // This might throw
48+
}
49+
const mightParseJSON = makeMightFailSync(parseJSON);
50+
51+
const [result, error] = mightParseJSON("");
52+
53+
if (error) {
54+
console.error("Parsing failed:", error);
55+
return;
56+
}
57+
58+
console.log("Parsed object:", result);
59+
```
60+
</Tab>
61+
</Tabs>

docs/content/getting-started/mightFail.mdx

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -117,57 +117,3 @@ posts.map((post) => console.log(post.title));
117117
</Tab>
118118
</Tabs>
119119

120-
## `makeMightFail`
121-
122-
You also have the option to make your own `mightFail` wrapper function. Pass in any async function to `makeMightFail` and it will return a `mightFail` wrapper function for you to use.
123-
124-
<Note>
125-
This is useful in some use cases, but most of the time you should just use `mightFail` directly.
126-
</Note>
127-
128-
<Tabs>
129-
<Tab name="tuple">
130-
```ts
131-
const get = makeMightFail(axios.get);
132-
const [ error, result ] = await get("/posts");
133-
134-
if (error) {
135-
// handle error
136-
return;
137-
}
138-
139-
const posts = result.data
140-
posts.map((post) => console.log(post.title));
141-
```
142-
</Tab>
143-
<Tab name="object">
144-
```ts
145-
const get = makeMightFail(axios.get);
146-
const { error, result } = await get("/posts");
147-
148-
if (error) {
149-
// handle error
150-
return;
151-
}
152-
153-
const posts = result.data
154-
posts.map((post) => console.log(post.title));
155-
```
156-
</Tab>
157-
<Tab name="go">
158-
```ts
159-
const get = makeMightFail(axios.get);
160-
const [ result, error ] = await get("/posts");
161-
162-
if (error) {
163-
// handle error
164-
return;
165-
}
166-
167-
const posts = result.data
168-
posts.map((post) => console.log(post.title));
169-
```
170-
</Tab>
171-
</Tabs>
172-
173-

docs/content/getting-started/mightFailSync.mdx

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -69,65 +69,3 @@ console.log('Parsed object:', result);
6969
```
7070
</Tab>
7171
</Tabs>
72-
73-
## `makeMightFailSync`
74-
75-
You also have the option to make your own `mightFailSync` wrapper function. Pass in any sync function to `makeMightFailSync` and it will return a `mightFailSync` wrapper function for you to use.
76-
77-
<Note>
78-
This is useful in some use cases, but most of the time you should just use `mightFailSync` directly.
79-
</Note>
80-
81-
<Tabs>
82-
<Tab name="tuple">
83-
```ts
84-
function parseJSON(jsonString: string) {
85-
return JSON.parse(jsonString); // This might throw
86-
}
87-
const mightParseJSON = makeMightFailSync(parseJSON);
88-
89-
const [error, result] = mightParseJSON("");
90-
91-
if (error) {
92-
console.error("Parsing failed:", error);
93-
return;
94-
}
95-
96-
console.log("Parsed object:", result);
97-
```
98-
</Tab>
99-
<Tab name="object">
100-
```ts
101-
function parseJSON(jsonString: string) {
102-
return JSON.parse(jsonString); // This might throw
103-
}
104-
const mightParseJSON = makeMightFailSync(parseJSON);
105-
106-
const { error, result } = mightParseJSON("");
107-
108-
if (error) {
109-
console.error("Parsing failed:", error);
110-
return;
111-
}
112-
113-
console.log("Parsed object:", result);
114-
```
115-
</Tab>
116-
<Tab name="go">
117-
```ts
118-
function parseJSON(jsonString: string) {
119-
return JSON.parse(jsonString); // This might throw
120-
}
121-
const mightParseJSON = makeMightFailSync(parseJSON);
122-
123-
const [result, error] = mightParseJSON("");
124-
125-
if (error) {
126-
console.error("Parsing failed:", error);
127-
return;
128-
}
129-
130-
console.log("Parsed object:", result);
131-
```
132-
</Tab>
133-
</Tabs>

0 commit comments

Comments
 (0)