11import { createLogger } from '@sim/logger'
22import { getNotificationUrl , getProviderConfig } from '@/lib/webhooks/provider-subscription-utils'
3+ import { WebhookDeploymentConfigurationError } from '@/lib/webhooks/providers/errors'
34import type {
45 DeleteSubscriptionContext ,
56 FormatInputContext ,
@@ -37,7 +38,7 @@ export const calendlyHandler: WebhookProviderHandler = {
3738 logger . warn ( `[${ ctx . requestId } ] Missing apiKey for Calendly webhook creation.` , {
3839 webhookId : ctx . webhook . id ,
3940 } )
40- throw new Error (
41+ throw new WebhookDeploymentConfigurationError (
4142 'Personal Access Token is required to create Calendly webhook. Please provide your Calendly Personal Access Token.'
4243 )
4344 }
@@ -46,7 +47,7 @@ export const calendlyHandler: WebhookProviderHandler = {
4647 logger . warn ( `[${ ctx . requestId } ] Missing organization URI for Calendly webhook creation.` , {
4748 webhookId : ctx . webhook . id ,
4849 } )
49- throw new Error (
50+ throw new WebhookDeploymentConfigurationError (
5051 'Organization URI is required to create Calendly webhook. Please provide your Organization URI from the "Get Current User" operation.'
5152 )
5253 }
@@ -55,7 +56,9 @@ export const calendlyHandler: WebhookProviderHandler = {
5556 logger . warn ( `[${ ctx . requestId } ] Missing triggerId for Calendly webhook creation.` , {
5657 webhookId : ctx . webhook . id ,
5758 } )
58- throw new Error ( 'Trigger ID is required to create Calendly webhook' )
59+ throw new WebhookDeploymentConfigurationError (
60+ 'Trigger ID is required to create Calendly webhook'
61+ )
5962 }
6063
6164 const notificationUrl = getNotificationUrl ( ctx . webhook )
@@ -152,6 +155,7 @@ export const calendlyHandler: WebhookProviderHandler = {
152155 )
153156 return { providerConfigUpdates : { externalId : webhookId } }
154157 } catch ( error : unknown ) {
158+ if ( error instanceof WebhookDeploymentConfigurationError ) throw error
155159 const err = error as Error
156160 logger . error (
157161 `[${ ctx . requestId } ] Exception during Calendly webhook creation for webhook ${ ctx . webhook . id } .` ,
0 commit comments