{"record":{"id":"230e54ee8f9725ee","repo":"calcom/cal.diy","slug":"httperror-message-errmsg","errorCode":null,"errorMessage":"httpError?.message ?? errMsg","messagePattern":"httpError\\?\\.message \\?\\? errMsg","errorType":"http","errorClass":"HttpException","httpStatus":500,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts","lineNumber":593,"sourceCode":"    if (requestBody?.responses?.guests?.length) {\n      requestBody.responses.guests = await this.platformBookingsService.getPlatformAttendeesEmails(\n        requestBody.responses.guests,\n        oAuthClientId\n      );\n    }\n  }\n\n  private handleBookingErrors(\n    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;","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts#L575-L611","documentation":"This is the message expression inside handleBookingErrors when the caught error is an instance of HttpError (Cal.com's domain error class with statusCode, message, url, method fields). The handler wraps it into a NestJS HttpException, preserving the original statusCode (defaulting to 500) and message (defaulting to the contextual errMsg like 'Error while creating recurring booking.'). It surfaces the upstream service's HTTP error to the API v2 caller.","triggerScenarios":"Any booking creation, cancellation, no-show, or recurring booking flow where the underlying service (regularBookingService, recurringBookingService, handleCancelBooking, handleMarkNoShow) throws a HttpError — for example when an availability check fails, a payment provider returns an error, or a conferencing integration call fails upstream.","commonSituations":"The booking service throws HttpError with a specific status like 409 for booking conflicts, 402 for payment failures, or 400 for bad input. The message and statusCode from the HttpError are forwarded. Common during double-booking attempts, expired payment sessions, or when an app-store integration (e.g., Stripe, Zoom) returns an error.","solutions":["Read the statusCode in the HTTP response — it reflects the original HttpError.statusCode and indicates the real problem (409 conflict, 402 payment, 400 bad request, etc.).","Address the root cause indicated by the statusCode: resolve scheduling conflicts, retry payments, fix input validation errors.","If the message is unhelpful, check server logs where the original HttpError was logged with its url, method, and data fields.","Ensure your client handles the full range of status codes (400, 402, 409, 500) that the booking service can emit."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Client-side: handle the propagated HttpError status codes\ntry {\n  await api.createBooking(payload);\n} catch (err) {\n  switch (err.statusCode) {\n    case 409: handleConflict(); break;\n    case 402: handlePaymentFailure(); break;\n    case 400: handleValidationError(err.message); break;\n    default: handleGenericError(err);\n  }\n}","preventionTips":["Handle the full range of HTTP status codes from booking endpoints — the statusCode reflects the original HttpError.","Log err.message and err.statusCode together for diagnostics.","For 409 conflicts, implement client-side availability checking before retrying.","For 402 payment errors, ensure payment credentials are valid before booking."],"tags":["error-handling","http-error","nestjs","booking","propagation"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}