Skip to content

fix: propagate and handle NO_FLIGHT_FOUND API errors properly#440

Open
VQToan wants to merge 1 commit into
etherisc:developfrom
VQToan:fix-no-matching-flight-found
Open

fix: propagate and handle NO_FLIGHT_FOUND API errors properly#440
VQToan wants to merge 1 commit into
etherisc:developfrom
VQToan:fix-no-matching-flight-found

Conversation

@VQToan
Copy link
Copy Markdown

@VQToan VQToan commented May 14, 2026

Fixes #275

Description

Preserves structured purchase-validation failures from the API route to the client. This surfaces specific messages like No matching flight found instead of a generic purchase failure, which occurs when the API route collapses validation failures into generic HTTP 500 errors or unhandled client-side exceptions.

Changes

  • Added custom FlightNotFoundError and InconsistentFlightDataError to errors.ts.
  • Updated purchase/route.ts to throw these typed errors during validateFlightPlan when flight stats are missing or mismatched, and to return structured JSON responses with specific error codes.
  • Updated use_local_api.tsx to parse these JSON responses and throw Error instances annotated with err.reason.
  • Updated use_application.tsx's catch block to look for err.reason === Reason.NO_FLIGHT_FOUND and Reason.INCONSISTENT_DATA, dispatching the exact translated UI error messages.
  • Fixed a bug where setError couldn't take a reason field in flightData.ts.

This PR was created with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: No matching flight found.

1 participant