{"record":{"id":"55228077cabfa25a","repo":"calcom/cal.diy","slug":"error-message-552280","errorCode":null,"errorMessage":"error.message","messagePattern":"error\\.message","errorType":"http","errorClass":"HttpException","httpStatus":400,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts","lineNumber":602,"sourceCode":"    err: Error | HttpError | unknown,\n    type?: \"recurring\" | `instant` | \"no-show\"\n  ): void {\n    const errMsg =\n      type === \"no-show\"\n        ? `Error while marking no-show.`\n        : `Error while creating ${type ? `${type} ` : \"\"}booking.`;\n    if (err instanceof HttpError) {\n      const httpError = err as HttpError;\n      throw new HttpException(httpError?.message ?? errMsg, httpError?.statusCode ?? 500);\n    }\n\n    if (err instanceof Error) {\n      const error = err as Error;\n      if (err instanceof HttpException) {\n        throw new HttpException(err.getResponse(), err.getStatus());\n      }\n      if (Object.values(ErrorCode).includes(error.message as unknown as ErrorCode)) {\n        throw new HttpException(error.message, 400);\n      }\n      throw new InternalServerErrorException(error?.message ?? errMsg);\n    }\n\n    throw new InternalServerErrorException(errMsg);\n  }\n\n  private transformToBoolean(v?: string): boolean {\n    return v && typeof v === \"string\" ? v.toLowerCase() === \"true\" : false;\n  }\n}\n","sourceCodeStart":584,"sourceCodeEnd":614,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts#L584-L614","documentation":"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.","triggerScenarios":"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').","commonSituations":"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).","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// Identify known ErrorCode values in the response\nimport { ErrorCode } from '@calcom/platform-libraries/errors';\n\nfunction isKnownErrorCode(message) {\n  return Object.values(ErrorCode).includes(message);\n}\n\n// Usage: if (isKnownErrorCode(err.message)) { /* handle domain error */ }","tryCatchPattern":"try {\n  await api.createBooking(payload);\n} catch (err) {\n  if (err.statusCode === 400 && isKnownErrorCode(err.message)) {\n    switch (err.message) {\n      case 'booking_conflict_error': handleSlotConflict(); break;\n      case 'not_enough_available_seats_error': handleSeatsFull(); break;\n      case 'booking_time_out_of_bounds_error': handleTimeWindow(); break;\n      default: handleOtherDomainError(err.message);\n    }\n  } else { throw err; }\n}","preventionTips":["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."],"tags":["error-handling","error-code","domain-error","nestjs","booking","validation"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}