Files
cal.diy/packages/app-store/stripepayment/lib/team-billing.ts
T
6e351a4b20 fix/premium-username-flow (#5815)
* Removes user plan logic for stripe sub

* Update hardcoded price

* Removed checkoutSessionId metadata and fix for trpc query

* Remove or comment team billing unused code

* Add todo note

* Fix type checks

* Change function that was renamed

* Remove duplicated test

* remove plan when creating user on test

Co-authored-by: Alex van Andel <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Peer Richelsen <[email protected]>
2022-12-07 12:55:47 -07:00

17 lines
787 B
TypeScript

import { PrismaClientKnownRequestError } from "@prisma/client/runtime";
export function getRequestedSlugError(error: unknown, requestedSlug: string) {
let message = `Unknown error`;
let statusCode = 500;
// This covers the edge case if an unpublished team takes too long to publish
// and another team gets the requestedSlug first.
// https://www.prisma.io/docs/reference/api-reference/error-reference#p2002
if (error instanceof PrismaClientKnownRequestError && error.code === "P2002") {
statusCode = 400;
message = `It seems like the requestedSlug: '${requestedSlug}' is already taken. Please contact support at [email protected] so we can resolve this issue.`;
} else if (error instanceof Error) {
message = error.message;
}
return { message, statusCode };
}