{"record":{"id":"d7acb462e5b4fd11","repo":"calcom/cal.diy","slug":"error-message-errmsg","errorCode":null,"errorMessage":"error?.message ?? errMsg","messagePattern":"error\\?\\.message \\?\\? errMsg","errorType":"http","errorClass":"InternalServerErrorException","httpStatus":500,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts","lineNumber":604,"sourceCode":"  ): 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":586,"sourceCodeEnd":614,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts#L586-L614","documentation":"This is the message expression inside handleBookingErrors for the generic Error branch — when the caught error is an Error instance but not an HttpError, not an HttpException, and its message doesn't match any ErrorCode enum value. The handler throws a 500 InternalServerErrorException with the error's message, falling back to the contextual errMsg (e.g., 'Error while creating recurring booking.').","triggerScenarios":"Any unexpected error during booking creation/cancellation/no-show that doesn't fit the typed error categories. Examples: Prisma database connection errors, serialization errors, null reference errors in the booking service, unexpected third-party API failures that throw plain Errors, or assertion failures.","commonSituations":"Database connectivity issues, transient Prisma errors (P1001 connection timed out), JSON parsing failures in metadata, missing required fields that bypass validation, or unhandled edge cases in the booking creation pipeline. This is the catch-all for genuinely unexpected errors.","solutions":["Check server logs for the full error stack trace — the original Error.message is forwarded but the stack is only in logs.","If the message references a database error (e.g., 'Connection refused', 'PrismaClientInitializationError'), check database connectivity and env vars (DIRECT_URL, DATABASE_URL).","If the message references a null/undefined access, inspect the booking request body for missing required fields.","File a bug report with the error message and the request payload (minus sensitive data) — this path indicates an unhandled error type."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await api.createBooking(payload);\n} catch (err) {\n  if (err.statusCode === 500) {\n    // Unexpected internal error — the message may contain a hint\n    console.error('Internal booking error:', err.message);\n    // Optionally retry with exponential backoff for transient errors\n    if (isTransientError(err.message)) {\n      await retryWithBackoff(() => api.createBooking(payload));\n    }\n  } else { throw err; }\n}","preventionTips":["Validate all required booking fields client-side before sending to reduce server-side errors.","Monitor 500 errors — they indicate bugs or infrastructure issues that need investigation.","Don't retry 500 errors blindly — some (like missing required fields) will fail identically.","Log the full error message and correlate with server logs using the X-Request-Id header."],"tags":["error-handling","internal-server-error","nestjs","booking","catch-all"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}