Skip to content

Commit 3d3331a

Browse files
committed
Refactor error handling in todos API POST method to use specific types for error properties
- Updated the error handling in the POST method of the todos API to utilize specific TypeScript types for error properties, enhancing type safety and clarity. - Improved the structure of the debug information to ensure better tracking of errors during API requests.
1 parent ce49d3f commit 3d3331a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

apps/web/src/app/api/todos/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export async function GET() {
112112

113113
// POST /api/todos - Create a new todo
114114
export async function POST(request: Request) {
115-
const debugInfo: any = {
115+
const debugInfo: DebugInfo = {
116116
timestamp: new Date().toISOString(),
117117
steps: [],
118118
};
@@ -170,9 +170,9 @@ export async function POST(request: Request) {
170170
message: error instanceof Error ? error.message : String(error),
171171
name: error instanceof Error ? error.name : "Unknown",
172172
stack: error instanceof Error ? error.stack : undefined,
173-
code: (error as any)?.code,
174-
detail: (error as any)?.detail,
175-
hint: (error as any)?.hint,
173+
code: (error as { code?: string })?.code,
174+
detail: (error as { detail?: string })?.detail,
175+
hint: (error as { hint?: string })?.hint,
176176
};
177177

178178
debugInfo.error = errorInfo;

0 commit comments

Comments
 (0)