calcom/cal.diy · error · HttpException
error.message
Error message
error.message
What it means
This is the message expression inside handleBookingErrors when the caught error is a plain Error whose message property exactly matches one of the ErrorCode enum values (e.g., 'booking_conflict_error', 'booking_not_found_error', 'event_type_not_found_error', 'booking_seats_full_error'). The handler maps these domain error codes to a 400 Bad Request HttpException.
Source
Thrown at apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts:602
err: Error | HttpError | unknown,
type?: "recurring" | `instant` | "no-show"
): void {
const errMsg =
type === "no-show"
? `Error while marking no-show.`
: `Error while creating ${type ? `${type} ` : ""}booking.`;
if (err instanceof HttpError) {
const httpError = err as HttpError;
throw new HttpException(httpError?.message ?? errMsg, httpError?.statusCode ?? 500);
}
if (err instanceof Error) {
const error = err as Error;
if (err instanceof HttpException) {
throw new HttpException(err.getResponse(), err.getStatus());
}
if (Object.values(ErrorCode).includes(error.message as unknown as ErrorCode)) {
throw new HttpException(error.message, 400);
}
throw new InternalServerErrorException(error?.message ?? errMsg);
}
throw new InternalServerErrorException(errMsg);
}
private transformToBoolean(v?: string): boolean {
return v && typeof v === "string" ? v.toLowerCase() === "true" : false;
}
}
View on GitHub (pinned to 176037d0af)
Solutions
- Map the ErrorCode string in the response to the specific domain problem — see packages/lib/errorCodes.ts for the full list of 40+ codes.
- For booking_conflict_error: pick a different time slot and retry.
- For not_enough_available_seats_error / booking_seats_full_error: reduce the number of seats requested or choose a different event type with more capacity.
- For booking_time_out_of_bounds_error: check the event type's minimumBookingNotice and schedulingWindow settings and pick a time within range.
- For booker_limit_exceeded_error: wait until the limit resets or contact the organizer.
Defensive patterns
Strategy: try-catch
Type guard
// Identify known ErrorCode values in the response
import { ErrorCode } from '@calcom/platform-libraries/errors';
function isKnownErrorCode(message) {
return Object.values(ErrorCode).includes(message);
}
// Usage: if (isKnownErrorCode(err.message)) { /* handle domain error */ } Try / catch
try {
await api.createBooking(payload);
} catch (err) {
if (err.statusCode === 400 && isKnownErrorCode(err.message)) {
switch (err.message) {
case 'booking_conflict_error': handleSlotConflict(); break;
case 'not_enough_available_seats_error': handleSeatsFull(); break;
case 'booking_time_out_of_bounds_error': handleTimeWindow(); break;
default: handleOtherDomainError(err.message);
}
} else { throw err; }
} Prevention
- Familiarize yourself with the ErrorCode enum (packages/lib/errorCodes.ts) — it lists 40+ known domain errors.
- Check time slot availability before booking to avoid booking_conflict_error.
- Verify seat capacity for seated events before booking to avoid booking_seats_full_error.
- Respect the event type's scheduling window (minBookingNotice, bookingWindow) to avoid booking_time_out_of_bounds_error.
When it happens
Trigger: The booking service or a downstream repository throws a plain Error with a message set to an ErrorCode string. This pattern is used when the service layer wants to signal a known domain error without coupling to NestJS exception classes. Examples: Error('booking_conflict_error'), Error('not_enough_available_seats_error'), Error('booking_time_out_of_bounds_error').
Common situations: Double-booking a time slot (booking_conflict_error), booking a seated event type that's full (booking_seats_full_error / not_enough_available_seats_error), requesting a time outside the allowed booking window (booking_time_out_of_bounds_error), referencing a deleted event type (event_type_not_found_error), or exceeding the booker's booking limit (booker_limit_exceeded_error).
Related errors
- Could not create recurring booking.
- httpError?.message ?? errMsg
- err.getResponse()
- error?.message ?? errMsg
- errMsg
AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12).
Data as JSON: /api/errors/55228077cabfa25a.
Report an issue: GitHub.