Skip to content

Commit 95f8046

Browse files
authored
refactor: Error code - remove circular dep between app store <-> lib (calcom#23669)
* remove stripe.types.ts * use stripe-error defined in packages/lib * refactor
1 parent d8a87e9 commit 95f8046

3 files changed

Lines changed: 20 additions & 64 deletions

File tree

packages/app-store/_utils/stripe.types.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

packages/lib/server/getServerErrorFromUnknown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Prisma } from "@prisma/client";
22
import type { ZodIssue } from "zod";
33
import { ZodError } from "zod";
44

5-
import { stripeInvalidRequestErrorSchema } from "@calcom/app-store/_utils/stripe.types";
65
import { ErrorCode } from "@calcom/lib/errorCodes";
76
import { ErrorWithCode } from "@calcom/lib/errors";
87

@@ -11,6 +10,7 @@ import { getHTTPStatusCodeFromError } from "@trpc/server/http";
1110

1211
import { HttpError } from "../http-error";
1312
import { redactError } from "../redactError";
13+
import { stripeInvalidRequestErrorSchema } from "../stripe-error";
1414

1515
function hasName(cause: unknown): cause is { name: string } {
1616
return !!cause && typeof cause === "object" && "name" in cause;

packages/lib/stripe-error.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { z } from "zod";
2+
3+
const errorSchema = z.object({
4+
name: z.string(),
5+
message: z.string(),
6+
stack: z.string().optional(),
7+
});
8+
9+
export const stripeInvalidRequestErrorSchema = errorSchema.extend({
10+
type: z.literal("StripeInvalidRequestError"),
11+
rawType: z.literal("invalid_request_error"),
12+
code: z.string().optional(),
13+
doc_url: z.string().optional(),
14+
statusCode: z.number().optional(),
15+
raw: z.unknown(),
16+
headers: z.record(z.string()),
17+
requestId: z.string(),
18+
param: z.string().optional(),
19+
});

0 commit comments

Comments
 (0)