Skip to content

Improve error handling and type safety in public.ts #196

@Harxhit

Description

@Harxhit

Summary

Improve type safety and error handling in public.ts by replacing unsafe catch block error access with getErrorMessage(err) and adding proper typing for the cl parameter in card.cardLinks.map().

File

apps/backend/src/routes/public.ts

Contexts

The public.ts route currently has two type-safety issues:

  1. Some catch blocks may directly access err.message or use inconsistent error handling patterns. Since TypeScript treats catch errors as unknown, this can lead to unsafe access and lint/type issues.

  2. The card.cardLinks.map() callback currently raises:

Parameter 'cl' implicitly has an 'any' type.

Adding an explicit or inferred type for cl will improve maintainability and ensure safer mapping logic.

A shared utility getErrorMessage(err: unknown): string already exists and should be used for standardized error extraction.

Tasks

  • Find catch blocks using unsafe error access in public.ts
  • Replace unsafe error handling with getErrorMessage(err)
  • Add proper typing for the cl parameter in card.cardLinks.map()
  • Ensure TypeScript and lint checks pass

Acceptance Criteria

  • Relevant catch blocks use getErrorMessage(err)
  • No unsafe err.message access remains in targeted code
  • cl no longer has implicit any type
  • Existing behavior remains unchanged
  • Tests added or updated if needed
  • Docs updated (if needed)

Area

backend

Difficulty

good first issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendcleanupCode cleanup, lint fixes, refactoring, and maintenance-related changes.good-first-issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions