diff --git a/app/api/leantime/status-labels/route.ts b/app/api/leantime/status-labels/route.ts index bfdfc006..4e2a2a39 100644 --- a/app/api/leantime/status-labels/route.ts +++ b/app/api/leantime/status-labels/route.ts @@ -65,15 +65,28 @@ export async function GET(request: NextRequest) { try { const session = await getServerSession(authOptions); - if (!session || !session.user?.email) { - return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); + if (!session) { + return NextResponse.json( + { error: "Unauthorized", message: "No session found. Please sign in." }, + { status: 401 } + ); + } + + if (!session.user?.email) { + return NextResponse.json( + { error: "Unauthorized", message: "No email found in session. Please sign in again." }, + { status: 401 } + ); } // Get Leantime user ID const leantimeUserId = await getLeantimeUserId(session.user.email); if (!leantimeUserId) { - return NextResponse.json({ error: "User not found in Leantime" }, { status: 404 }); + return NextResponse.json( + { error: "User not found", message: "Could not find user in Leantime. Please check your email." }, + { status: 404 } + ); } // Get all tasks assigned to the user @@ -184,7 +197,7 @@ export async function GET(request: NextRequest) { } catch (error) { console.error('Error fetching status labels:', error); return NextResponse.json( - { error: "Failed to fetch status labels" }, + { error: "Failed to fetch status labels", message: error instanceof Error ? error.message : "Unknown error occurred" }, { status: 500 } ); }