feat: wrap article and user service functions with TypedResult for improved error handling
This commit is contained in:
@@ -70,7 +70,9 @@ const ArticleContentSkeleton = () => (
|
||||
|
||||
const ArticleContent = async ({ params }: ArticleContentProps) => {
|
||||
const { slug } = await params;
|
||||
const article = await getArticleBySlug(slug);
|
||||
const articleResult = await getArticleBySlug(slug);
|
||||
if (!articleResult.ok) throw articleResult.error;
|
||||
const article = articleResult.value;
|
||||
|
||||
if (!article) notFound();
|
||||
|
||||
|
||||
@@ -45,11 +45,9 @@ const ArticleList = async ({ searchParams }: ArticleListProps) => {
|
||||
const page = Math.max(1, Number(pageParam) || 1);
|
||||
const pageSize = Number(pageSizeParam) || PAGE_SIZE;
|
||||
|
||||
const {
|
||||
data: articles,
|
||||
totalPages,
|
||||
total,
|
||||
} = await getArticlesPaginated(page, pageSize);
|
||||
const paginationResult = await getArticlesPaginated(page, pageSize);
|
||||
if (!paginationResult.ok) throw paginationResult.error;
|
||||
const { data: articles, totalPages, total } = paginationResult.value;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user