refactor: Error code - remove circular dep between app store <-> lib (#23669)
* remove stripe.types.ts * use stripe-error defined in packages/lib * refactor
This commit is contained in:
1 parent
d8a87e9f04
commit
95f8046db9
3 files changed
+20
-64
No files matched your search
@@ -2,7 +2,6 @@ import { Prisma } from "@prisma/client";
|
||||
import type { ZodIssue } from "zod";
|
||||
import { ZodError } from "zod";
|
||||
|
||||
import { stripeInvalidRequestErrorSchema } from "@calcom/app-store/_utils/stripe.types";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { ErrorWithCode } from "@calcom/lib/errors";
|
||||
|
||||
@@ -11,6 +10,7 @@ import { getHTTPStatusCodeFromError } from "@trpc/server/http";
|
||||
|
||||
import { HttpError } from "../http-error";
|
||||
import { redactError } from "../redactError";
|
||||
import { stripeInvalidRequestErrorSchema } from "../stripe-error";
|
||||
|
||||
function hasName(cause: unknown): cause is { name: string } {
|
||||
return !!cause && typeof cause === "object" && "name" in cause;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const errorSchema = z.object({
|
||||
name: z.string(),
|
||||
message: z.string(),
|
||||
stack: z.string().optional(),
|
||||
});
|
||||
|
||||
export const stripeInvalidRequestErrorSchema = errorSchema.extend({
|
||||
type: z.literal("StripeInvalidRequestError"),
|
||||
rawType: z.literal("invalid_request_error"),
|
||||
code: z.string().optional(),
|
||||
doc_url: z.string().optional(),
|
||||
statusCode: z.number().optional(),
|
||||
raw: z.unknown(),
|
||||
headers: z.record(z.string()),
|
||||
requestId: z.string(),
|
||||
param: z.string().optional(),
|
||||
});
|
||||
Reference in new issue
Block a user