@@ -80,19 +80,23 @@ public function notify_appointment_saved(
80
80
$ subject = $ manage_mode ? lang ('appointment_details_changed ' ) : lang ('appointment_booked ' );
81
81
$ message = $ manage_mode ? '' : lang ('thank_you_for_appointment ' );
82
82
83
- $ this ->CI ->email_messages ->send_appointment_saved (
84
- $ appointment ,
85
- $ provider ,
86
- $ service ,
87
- $ customer ,
88
- $ settings ,
89
- $ subject ,
90
- $ message ,
91
- $ customer_link ,
92
- $ customer ['email ' ],
93
- $ ics_stream ,
94
- $ customer ['timezone ' ],
95
- );
83
+ try {
84
+ $ this ->CI ->email_messages ->send_appointment_saved (
85
+ $ appointment ,
86
+ $ provider ,
87
+ $ service ,
88
+ $ customer ,
89
+ $ settings ,
90
+ $ subject ,
91
+ $ message ,
92
+ $ customer_link ,
93
+ $ customer ['email ' ],
94
+ $ ics_stream ,
95
+ $ customer ['timezone ' ],
96
+ );
97
+ } catch (Throwable $ e ) {
98
+ $ this ->log_exception ($ e , 'appointment-saved to customer ' , $ appointment ['id ' ] ?? null );
99
+ }
96
100
}
97
101
98
102
// Notify provider.
@@ -107,19 +111,23 @@ public function notify_appointment_saved(
107
111
$ subject = $ manage_mode ? lang ('appointment_details_changed ' ) : lang ('appointment_added_to_your_plan ' );
108
112
$ message = $ manage_mode ? '' : lang ('appointment_link_description ' );
109
113
110
- $ this ->CI ->email_messages ->send_appointment_saved (
111
- $ appointment ,
112
- $ provider ,
113
- $ service ,
114
- $ customer ,
115
- $ settings ,
116
- $ subject ,
117
- $ message ,
118
- $ provider_link ,
119
- $ provider ['email ' ],
120
- $ ics_stream ,
121
- $ provider ['timezone ' ],
122
- );
114
+ try {
115
+ $ this ->CI ->email_messages ->send_appointment_saved (
116
+ $ appointment ,
117
+ $ provider ,
118
+ $ service ,
119
+ $ customer ,
120
+ $ settings ,
121
+ $ subject ,
122
+ $ message ,
123
+ $ provider_link ,
124
+ $ provider ['email ' ],
125
+ $ ics_stream ,
126
+ $ provider ['timezone ' ],
127
+ );
128
+ } catch (Throwable $ e ) {
129
+ $ this ->log_exception ($ e , 'appointment-saved to provider ' , $ appointment ['id ' ] ?? null );
130
+ }
123
131
}
124
132
125
133
// Notify admins.
@@ -135,19 +143,23 @@ public function notify_appointment_saved(
135
143
$ subject = $ manage_mode ? lang ('appointment_details_changed ' ) : lang ('appointment_added_to_your_plan ' );
136
144
$ message = $ manage_mode ? '' : lang ('appointment_link_description ' );
137
145
138
- $ this ->CI ->email_messages ->send_appointment_saved (
139
- $ appointment ,
140
- $ provider ,
141
- $ service ,
142
- $ customer ,
143
- $ settings ,
144
- $ subject ,
145
- $ message ,
146
- $ provider_link ,
147
- $ admin ['email ' ],
148
- $ ics_stream ,
149
- $ admin ['timezone ' ],
150
- );
146
+ try {
147
+ $ this ->CI ->email_messages ->send_appointment_saved (
148
+ $ appointment ,
149
+ $ provider ,
150
+ $ service ,
151
+ $ customer ,
152
+ $ settings ,
153
+ $ subject ,
154
+ $ message ,
155
+ $ provider_link ,
156
+ $ admin ['email ' ],
157
+ $ ics_stream ,
158
+ $ admin ['timezone ' ],
159
+ );
160
+ } catch (Throwable $ e ) {
161
+ $ this ->log_exception ($ e , 'appointment-saved to admin ' , $ appointment ['id ' ] ?? null );
162
+ }
151
163
}
152
164
153
165
// Notify secretaries.
@@ -167,29 +179,26 @@ public function notify_appointment_saved(
167
179
$ subject = $ manage_mode ? lang ('appointment_details_changed ' ) : lang ('appointment_added_to_your_plan ' );
168
180
$ message = $ manage_mode ? '' : lang ('appointment_link_description ' );
169
181
170
- $ this ->CI ->email_messages ->send_appointment_saved (
171
- $ appointment ,
172
- $ provider ,
173
- $ service ,
174
- $ customer ,
175
- $ settings ,
176
- $ subject ,
177
- $ message ,
178
- $ provider_link ,
179
- $ secretary ['email ' ],
180
- $ ics_stream ,
181
- $ secretary ['timezone ' ],
182
- );
182
+ try {
183
+ $ this ->CI ->email_messages ->send_appointment_saved (
184
+ $ appointment ,
185
+ $ provider ,
186
+ $ service ,
187
+ $ customer ,
188
+ $ settings ,
189
+ $ subject ,
190
+ $ message ,
191
+ $ provider_link ,
192
+ $ secretary ['email ' ],
193
+ $ ics_stream ,
194
+ $ secretary ['timezone ' ],
195
+ );
196
+ } catch (Throwable $ e ) {
197
+ $ this ->log_exception ($ e , 'appointment-saved to secretary ' , $ appointment ['id ' ] ?? null );
198
+ }
183
199
}
184
200
} catch (Throwable $ e ) {
185
- log_message (
186
- 'error ' ,
187
- 'Notifications - Could not email confirmation details of appointment ( ' .
188
- ($ appointment ['id ' ] ?? '- ' ) .
189
- ') : ' .
190
- $ e ->getMessage (),
191
- );
192
- log_message ('error ' , $ e ->getTraceAsString ());
201
+ $ this ->log_exception ($ e , 'appointment-saved (general exception) ' , $ appointment ['id ' ] ?? null );
193
202
} finally {
194
203
config (['language ' => $ current_language ?? 'english ' ]);
195
204
$ this ->CI ->lang ->load ('translations ' );
@@ -226,16 +235,20 @@ public function notify_appointment_deleted(
226
235
config (['language ' => $ provider ['language ' ]]);
227
236
$ this ->CI ->lang ->load ('translations ' );
228
237
229
- $ this ->CI ->email_messages ->send_appointment_deleted (
230
- $ appointment ,
231
- $ provider ,
232
- $ service ,
233
- $ customer ,
234
- $ settings ,
235
- $ provider ['email ' ],
236
- $ cancellation_reason ,
237
- $ provider ['timezone ' ],
238
- );
238
+ try {
239
+ $ this ->CI ->email_messages ->send_appointment_deleted (
240
+ $ appointment ,
241
+ $ provider ,
242
+ $ service ,
243
+ $ customer ,
244
+ $ settings ,
245
+ $ provider ['email ' ],
246
+ $ cancellation_reason ,
247
+ $ provider ['timezone ' ],
248
+ );
249
+ } catch (Throwable $ e ) {
250
+ $ this ->log_exception ($ e , 'appointment-deleted to provider ' , $ appointment ['id ' ] ?? null );
251
+ }
239
252
}
240
253
241
254
// Notify customer.
@@ -246,16 +259,20 @@ public function notify_appointment_deleted(
246
259
config (['language ' => $ customer ['language ' ]]);
247
260
$ this ->CI ->lang ->load ('translations ' );
248
261
249
- $ this ->CI ->email_messages ->send_appointment_deleted (
250
- $ appointment ,
251
- $ provider ,
252
- $ service ,
253
- $ customer ,
254
- $ settings ,
255
- $ customer ['email ' ],
256
- $ cancellation_reason ,
257
- $ customer ['timezone ' ],
258
- );
262
+ try {
263
+ $ this ->CI ->email_messages ->send_appointment_deleted (
264
+ $ appointment ,
265
+ $ provider ,
266
+ $ service ,
267
+ $ customer ,
268
+ $ settings ,
269
+ $ customer ['email ' ],
270
+ $ cancellation_reason ,
271
+ $ customer ['timezone ' ],
272
+ );
273
+ } catch (Throwable $ e ) {
274
+ $ this ->log_exception ($ e , 'appointment-deleted to customer ' , $ appointment ['id ' ] ?? null );
275
+ }
259
276
}
260
277
261
278
// Notify admins.
@@ -269,16 +286,20 @@ public function notify_appointment_deleted(
269
286
config (['language ' => $ admin ['language ' ]]);
270
287
$ this ->CI ->lang ->load ('translations ' );
271
288
272
- $ this ->CI ->email_messages ->send_appointment_deleted (
273
- $ appointment ,
274
- $ provider ,
275
- $ service ,
276
- $ customer ,
277
- $ settings ,
278
- $ admin ['email ' ],
279
- $ cancellation_reason ,
280
- $ admin ['timezone ' ],
281
- );
289
+ try {
290
+ $ this ->CI ->email_messages ->send_appointment_deleted (
291
+ $ appointment ,
292
+ $ provider ,
293
+ $ service ,
294
+ $ customer ,
295
+ $ settings ,
296
+ $ admin ['email ' ],
297
+ $ cancellation_reason ,
298
+ $ admin ['timezone ' ],
299
+ );
300
+ } catch (Throwable $ e ) {
301
+ $ this ->log_exception ($ e , 'appointment-deleted to admin ' , $ appointment ['id ' ] ?? null );
302
+ }
282
303
}
283
304
284
305
// Notify secretaries.
@@ -296,16 +317,20 @@ public function notify_appointment_deleted(
296
317
config (['language ' => $ secretary ['language ' ]]);
297
318
$ this ->CI ->lang ->load ('translations ' );
298
319
299
- $ this ->CI ->email_messages ->send_appointment_deleted (
300
- $ appointment ,
301
- $ provider ,
302
- $ service ,
303
- $ customer ,
304
- $ settings ,
305
- $ secretary ['email ' ],
306
- $ cancellation_reason ,
307
- $ secretary ['timezone ' ],
308
- );
320
+ try {
321
+ $ this ->CI ->email_messages ->send_appointment_deleted (
322
+ $ appointment ,
323
+ $ provider ,
324
+ $ service ,
325
+ $ customer ,
326
+ $ settings ,
327
+ $ secretary ['email ' ],
328
+ $ cancellation_reason ,
329
+ $ secretary ['timezone ' ],
330
+ );
331
+ } catch (Throwable $ e ) {
332
+ $ this ->log_exception ($ e , 'appointment-deleted to secretary ' , $ appointment ['id ' ] ?? null );
333
+ }
309
334
}
310
335
} catch (Throwable $ e ) {
311
336
log_message (
@@ -321,4 +346,13 @@ public function notify_appointment_deleted(
321
346
$ this ->CI ->lang ->load ('translations ' );
322
347
}
323
348
}
349
+
350
+ private function log_exception (Throwable $ e , string $ message , ?int $ appointment_id ): void
351
+ {
352
+ log_message (
353
+ 'error ' ,
354
+ 'Notifications - Could not email ' . $ message . ' ( ' . ($ appointment_id ?? '- ' ) . ') : ' . $ e ->getMessage (),
355
+ );
356
+ log_message ('error ' , $ e ->getTraceAsString ());
357
+ }
324
358
}
0 commit comments