refactor: consolidate error handlers to use getServerErrorFromUnknown (#25114)

* refactor: consolidate error handlers to use getServerErrorFromUnknown

- Migrate server-only code to use getServerErrorFromUnknown for better error handling
- Add JSDoc documentation to both getErrorFromUnknown and getServerErrorFromUnknown
- Update webhook handlers, payment services, email service, and booking service
- Keep getErrorFromUnknown for client-side and isomorphic code
- Improve error message extraction by using err.cause?.stack instead of err.stack
- Fix ESLint warnings: replace 'any' with 'unknown' types, fix hasOwnProperty usage

Co-Authored-By: [email protected] <[email protected]>

* Update packages/app-store/paypal/api/webhook.ts

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* refactor

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2025-11-28 09:14:06 +01:00
1 parent 724204843a
commit e6ba89961c
12 files changed
+61 -38

No files matched your search

@@ -33,6 +33,12 @@ function parseZodErrorIssues(issues: ZodIssue[]): string {
.join("; ");
}
/**
* Converts unknown error types to HttpError with proper status code mapping and error redaction.
* SERVER-ONLY: This function imports Prisma and Stripe schemas and should only be used in server-side code.
* Use in API routes, tRPC handlers, webhooks, and server-side services.
* For client-side code, use getErrorFromUnknown from @calcom/lib/errors instead.
*/
export function getServerErrorFromUnknown(cause: unknown): HttpError {
if (isZodError(cause)) {
return new HttpError({