feat: wrap article and user service functions with TypedResult for improved error handling

This commit is contained in:
2026-04-11 01:48:09 -03:00
parent 94e8058880
commit af17b6dc5a
10 changed files with 363 additions and 240 deletions

View File

@@ -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();

View File

@@ -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 (
<>