fix: adds try...catch in all services (#2494)

Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
This commit is contained in:
Piyush Gupta
2024-04-22 12:45:37 +05:30
committed by GitHub
parent ed509d3a9a
commit 4ee27f9618
33 changed files with 1686 additions and 1229 deletions
@@ -8,12 +8,17 @@ export const sendFreeLimitReachedEventToPosthogBiWeekly = async (
): Promise<string> =>
unstable_cache(
async () => {
await capturePosthogEnvironmentEvent(environmentId, "free limit reached", {
plan,
});
return "success";
try {
await capturePosthogEnvironmentEvent(environmentId, "free limit reached", {
plan,
});
return "success";
} catch (error) {
console.error(error);
throw error;
}
},
[`posthog-${plan}-limitReached-${environmentId}`],
[`sendFreeLimitReachedEventToPosthogBiWeekly-${plan}-${environmentId}`],
{
revalidate: 60 * 60 * 24 * 15, // 15 days
}
+1 -1
View File
@@ -104,7 +104,7 @@ export async function POST(request: Request) {
return Response.json(user);
} catch (e) {
if (e.code === "P2002") {
if (e.message === "User with this email already exists") {
return Response.json(
{
error: "user with this email address already exists",