diff --git a/src/routing/matchRoute/matchRoute.spec.ts b/src/routing/matchRoute/matchRoute.spec.ts index 101f4fd..c671fc7 100644 --- a/src/routing/matchRoute/matchRoute.spec.ts +++ b/src/routing/matchRoute/matchRoute.spec.ts @@ -42,8 +42,9 @@ describe("matchRoute", () => { }); it("returns a match-error type if there is a problem parsing the query/params schema", () => { - expect(matchRoute(routes, "", "/route2", "?foo=123")).toEqual({ + expect(matchRoute(routes, "", "/route2", "?foo=123")).toMatchObject({ type: "match-error", + error: expect.any(Error), }); }); diff --git a/src/routing/matchRoute/matchRoute.ts b/src/routing/matchRoute/matchRoute.ts index dc0d913..29434fc 100644 --- a/src/routing/matchRoute/matchRoute.ts +++ b/src/routing/matchRoute/matchRoute.ts @@ -8,7 +8,7 @@ type Return[]> = event: RoutingEvent; } | { type: "no-matches" } - | { type: "match-error" }; + | { type: "match-error"; error: unknown }; /** * @public @@ -48,7 +48,7 @@ export function matchRoute[]>( if (matchingRoute === undefined) { return { type: "no-matches" }; } else if (matchingRoute instanceof Error) { - return { type: "match-error" }; + return { type: "match-error", error: matchingRoute }; } return { type: "matched", route: matchingRoute, event: event as any };