Skip to content

Commit 4d7bb21

Browse files
committed
refactor(handler): rename function from runWithHandleErrorIf to runWithHandleError
1 parent 0e57e49 commit 4d7bb21

10 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/app/[...slug]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "../../models/models";
1212
import { asInsight } from "../../utils/insight";
1313
import { sluggize } from "../../utils/url";
14-
import { parseOrThrow, runWithHandleErrorIf } from "../handler";
14+
import { parseOrThrow, runWithHandleError } from "../handler";
1515
import { generateForArticleOrPage } from "../metadata";
1616
import { Renderer } from "./renderer";
1717

@@ -43,7 +43,7 @@ export default async function Page(req: any) {
4343
const { props } = await handler(r);
4444
return <Renderer {...props} />;
4545
};
46-
return runWithHandleErrorIf(await fn(req));
46+
return runWithHandleError(await fn(req));
4747
}
4848

4949
async function handler(req: any) {

src/app/archives/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import { headers } from "next/headers";
44
import { fetchArchives } from "../../api";
55
import { Archive, ArchiveResponse } from "../../models/models";
6-
import { parseOrThrow, runWithHandleErrorIf } from "../handler";
6+
import { parseOrThrow, runWithHandleError } from "../handler";
77
import { Renderer } from "./renderer";
88

99
export default async function Page(req: any) {
1010
const fn = async (r: any): Promise<any> => {
1111
const { props } = await handler(r);
1212
return <Renderer {...props} />;
1313
};
14-
return runWithHandleErrorIf(await fn(req));
14+
return runWithHandleError(await fn(req));
1515
}
1616

1717
async function handler(req: any) {

src/app/articles/[...slug]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { asInsight } from "../../../utils/insight";
1414
import { isMatch } from "../../../utils/match";
1515
import { sluggize } from "../../../utils/url";
16-
import { parseOrThrow, runWithHandleErrorIf } from "../../handler";
16+
import { parseOrThrow, runWithHandleError } from "../../handler";
1717
import { generateForArticleOrPage } from "../../metadata";
1818
import { Renderer } from "./renderer";
1919

@@ -47,7 +47,7 @@ export default async function Page(req: any) {
4747
const { props } = await handler(r);
4848
return <Renderer {...props} />;
4949
};
50-
return runWithHandleErrorIf(await fn(req));
50+
return runWithHandleError(await fn(req));
5151
}
5252

5353
async function handler(req: any) {

src/app/articles/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { headers } from "next/headers";
44
import { fetchArticles } from "../../api";
55
import { getValidOrder, isRandomOrder } from "../../api/order";
66
import { Article, ArticleResponseWithCount } from "../../models/models";
7-
import { parseOrThrow, runWithHandleErrorIf } from "../handler";
7+
import { parseOrThrow, runWithHandleError } from "../handler";
88
import { Renderer } from "./renderer";
99

1010
export default async function Page(req: any) {
1111
const fn = async (r: any): Promise<any> => {
1212
const { props } = await handler(r);
1313
return <Renderer {...props} />;
1414
};
15-
return runWithHandleErrorIf(await fn(req));
15+
return runWithHandleError(await fn(req));
1616
}
1717

1818
async function handler(req: any) {

src/app/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { notFound } from "next/navigation";
22

33
// TODO: write test code
4-
export async function runWithHandleErrorIf(
4+
export async function runWithHandleError(
55
fn: (arg: any) => React.FunctionComponent
66
): Promise<any> {
77
try {

src/app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { headers } from "next/headers";
44
import { fetchArticles } from "../api";
55
import { Order } from "../api/order";
66
import { Article, ArticleResponseWithCount } from "../models/models";
7-
import { parseOrThrow, runWithHandleErrorIf } from "./handler";
7+
import { parseOrThrow, runWithHandleError } from "./handler";
88
import { Renderer } from "./renderer";
99

1010
export default async function Page(req: any) {
1111
const fn = async (r: any): Promise<any> => {
1212
const { props } = await handler(r);
1313
return <Renderer {...props} />;
1414
};
15-
return runWithHandleErrorIf(await fn(req));
15+
return runWithHandleError(await fn(req));
1616
}
1717

1818
async function handler(req: any) {

src/app/series/[slug]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import {
77
SeriresWithArticles,
88
SeriresWithArticlesResponse
99
} from "../../../models/models";
10-
import { parseOrThrow, runWithHandleErrorIf } from "../../handler";
10+
import { parseOrThrow, runWithHandleError } from "../../handler";
1111
import { Renderer } from "./renderer";
1212

1313
export default async function Page(req: any) {
1414
const fn = async (r: any): Promise<any> => {
1515
const { props } = await handler(r);
1616
return <Renderer {...props} />;
1717
};
18-
return runWithHandleErrorIf(await fn(req));
18+
return runWithHandleError(await fn(req));
1919
}
2020

2121
async function handler(req: any) {

src/app/series/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import { headers } from "next/headers";
44
import { fetchAllSeries } from "../../api";
55
import { Series, SeriesResponse } from "../../models/models";
6-
import { parseOrThrow, runWithHandleErrorIf } from "../handler";
6+
import { parseOrThrow, runWithHandleError } from "../handler";
77
import { Renderer } from "./renderer";
88

99
export default async function Page(req: any) {
1010
const fn = async (r: any): Promise<any> => {
1111
const { props } = await handler(r);
1212
return <Renderer {...props} />;
1313
};
14-
return runWithHandleErrorIf(await fn(req));
14+
return runWithHandleError(await fn(req));
1515
}
1616

1717
async function handler(req: any) {

src/app/tags/[...slug]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { headers } from "next/headers";
44
import { fetchTag } from "../../../api";
55
import { getValidOrder, isRandomOrder } from "../../../api/order";
66
import { Article, ArticleResponseWithCount } from "../../../models/models";
7-
import { parseOrThrow, runWithHandleErrorIf } from "../../handler";
7+
import { parseOrThrow, runWithHandleError } from "../../handler";
88
import { Renderer } from "./renderer";
99

1010
export default async function Page(req: any) {
1111
const fn = async (r: any): Promise<any> => {
1212
const { props } = await handler(r);
1313
return <Renderer {...props} />;
1414
};
15-
return runWithHandleErrorIf(await fn(req));
15+
return runWithHandleError(await fn(req));
1616
}
1717

1818
async function handler(req: any) {

src/app/tags/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import { headers } from "next/headers";
44
import { fetchAllTags } from "../../api";
55
import { Tag } from "../../models/models";
6-
import { parseOrThrow, runWithHandleErrorIf } from "../handler";
6+
import { parseOrThrow, runWithHandleError } from "../handler";
77
import { Renderer } from "./renderer";
88

99
export default async function Page(req: any) {
1010
const fn = async (r: any): Promise<any> => {
1111
const { props } = await handler(r);
1212
return <Renderer {...props} />;
1313
};
14-
return runWithHandleErrorIf(await fn(req));
14+
return runWithHandleError(await fn(req));
1515
}
1616

1717
async function handler(req: any) {

0 commit comments

Comments
 (0)