feat: Leverage ErrorCode cases for correct error codes in server responses (#22023)

* Leverage ErrorCode cases for correct error codes in server responses

* better test

* fix
This commit is contained in:
Benny Joo authored and GitHub committed 2025-06-25 13:18:01 -07:00
1 parent 79a0071d65
commit d50e1a0e15
3 files changed
+136 -24

No files matched your search

@@ -52,7 +52,6 @@ import {
getFirstDelegationConferencingCredentialAppLocation,
} from "@calcom/lib/delegationCredential/server";
import { ErrorCode } from "@calcom/lib/errorCodes";
import type { ErrorWithCode } from "@calcom/lib/errors";
import { getErrorFromUnknown } from "@calcom/lib/errors";
import { getEventName, updateHostInEventName } from "@calcom/lib/event";
import { extractBaseEmail } from "@calcom/lib/extract-base-email";
@@ -455,22 +454,12 @@ async function handler(
await checkIfBookerEmailIsBlocked({ loggedInUserId: userId, bookerEmail });
if (!rawBookingData.rescheduleUid) {
try {
await checkActiveBookingsLimitForBooker({
eventTypeId,
maxActiveBookingsPerBooker: eventType.maxActiveBookingsPerBooker,
bookerEmail,
offerToRescheduleLastBooking: eventType.maxActiveBookingPerBookerOfferReschedule,
});
} catch (err) {
const error = err as ErrorWithCode;
throw new HttpError({
statusCode: 400,
message: error.message,
data: error.data,
});
}
await checkActiveBookingsLimitForBooker({
eventTypeId,
maxActiveBookingsPerBooker: eventType.maxActiveBookingsPerBooker,
bookerEmail,
offerToRescheduleLastBooking: eventType.maxActiveBookingPerBookerOfferReschedule,
});
}
if (isEventTypeLoggingEnabled({ eventTypeId, usernameOrTeamName: reqBody.user })) {