{"record":{"id":"0efebab6b8790768","repo":"calcom/cal.diy","slug":"errmsg","errorCode":null,"errorMessage":"errMsg","messagePattern":"errMsg","errorType":"http","errorClass":"InternalServerErrorException","httpStatus":500,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts","lineNumber":607,"sourceCode":"        ? `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":589,"sourceCodeEnd":614,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts#L589-L614","documentation":"This is the final fallback message inside handleBookingErrors for the 'unknown' error type — when the caught value is neither an HttpError nor an Error instance. This happens when something non-standard is thrown (a string, number, plain object, null, or undefined). The handler throws a 500 InternalServerErrorException with only the contextual errMsg, since there's no .message property to extract.","triggerScenarios":"Code somewhere in the booking pipeline does throw 'some string' or throw { code: 123 } instead of throwing a proper Error subclass. Also triggered if a Promise rejection reason is a non-Error value, or if a library internally throws a non-Error.","commonSituations":"A third-party library or app-store integration throws a non-Error value. Internal code that was quickly written with throw 'message' instead of throw new Error('message'). A Promise.reject('reason') without wrapping in Error. This path loses all diagnostic detail since only the generic errMsg is available.","solutions":["Search the booking service codebase for bare 'throw' statements that throw non-Error values and replace them with throw new Error(...).","Check third-party integration code (app-store apps) for non-Error throws.","Add logging before this throw to capture the actual value of err (e.g., JSON.stringify or util.inspect) for debugging.","If you see this in production, reproduce locally with verbose logging to capture the non-Error value's shape."],"exampleFix":"// before — non-Error throw somewhere in the pipeline\nif (!slot) throw 'No slot available';\n\n// after — proper Error\nif (!slot) throw new Error('No slot available');","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await api.createBooking(payload);\n} catch (err) {\n  if (err.statusCode === 500 && err.message.startsWith('Error while')) {\n    // This is the unknown-type fallback — minimal diagnostic info available\n    console.error('Unhandled error type in booking flow. Request:', payload);\n    // Report to Cal.com with the request details for investigation\n  } else { throw err; }\n}","preventionTips":["If you're a platform developer, never throw non-Error values — always use throw new Error(...) or a subclass.","Audit app-store integrations for non-Error throws.","Add server-side logging before the final fallback throw to capture the actual error value.","Report recurring instances of this error to Cal.com — it indicates a code quality issue in the pipeline."],"tags":["error-handling","internal-server-error","unknown-type","nestjs","booking","catch-all"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}