@@ -34,8 +34,7 @@ func calculateOccurrences(ctx context.Context, meeting meetingInput, pastOccurre
3434
3535 meetingStartTime , err := time .Parse (time .RFC3339 , meeting .StartTime )
3636 if err != nil {
37- logger .With (errKey , err , "meeting_id" , meeting .ID , "start_time" , meeting .StartTime ).ErrorContext (ctx , "failed to parse meeting start_time" )
38- return nil , err
37+ return nil , fmt .Errorf ("failed to parse meeting start_time %s: %w" , meeting .StartTime , err )
3938 }
4039
4140 location := time .UTC
@@ -71,8 +70,7 @@ func calculateOccurrences(ctx context.Context, meeting meetingInput, pastOccurre
7170 // Convert occurrence start time to timeRFC3339 format to make the time easier to read in the logs
7271 occurrenceStartTimeUnixInt , err := strconv .ParseInt (occurrenceStartTimeUnix , 10 , 64 )
7372 if err != nil {
74- logger .With (errKey , err , "meeting_id" , meeting .ID , "occurrence_id" , occurrenceStartTimeUnix , "occurrence_start_time" , occurrenceStartTimeFmt ).ErrorContext (ctx , "failed to parse occurrence start_time" )
75- return nil , err
73+ return nil , fmt .Errorf ("failed to convert occurrence start time %s to int: %w" , occurrenceStartTimeUnix , err )
7674 }
7775 occurrenceStartTimeFmt = time .Unix (occurrenceStartTimeUnixInt , 0 ).Format (time .RFC3339 )
7876 }
@@ -113,8 +111,7 @@ func calculateOccurrences(ctx context.Context, meeting meetingInput, pastOccurre
113111 if occurrencePatternIdx < len (occurrencesPattern )- 1 && occurrencesPattern [occurrencePatternIdx + 1 ].OccurrenceID != "" {
114112 nextRecurrenceTimeUnix , err = strconv .ParseInt (occurrencesPattern [occurrencePatternIdx + 1 ].OccurrenceID , 10 , 64 )
115113 if err != nil {
116- logger .With (errKey , err , "meeting_id" , meeting .ID , "next_recurrence_occurrence_id" , occurrencesPattern [occurrencePatternIdx + 1 ].OccurrenceID , "next_recurrence_start_time" , occurrencesPattern [occurrencePatternIdx + 1 ].StartTime ).ErrorContext (ctx , "failed to parse next recurrence start_time" )
117- return nil , err
114+ return nil , fmt .Errorf ("failed to convert next recurrence start time %s to int: %w" , occurrencesPattern [occurrencePatternIdx + 1 ].OccurrenceID , err )
118115 }
119116 }
120117 logger .With ("meeting_id" , meeting .ID , "current_recurrence" , occurrencePattern , "next_recurrence_start_time_unix" , nextRecurrenceTimeUnix , "next_recurrence_start_time" , time .Unix (nextRecurrenceTimeUnix , 0 ).Format (time .RFC3339 )).DebugContext (ctx , "next recurrence start time" )
@@ -130,8 +127,7 @@ func calculateOccurrences(ctx context.Context, meeting meetingInput, pastOccurre
130127 // Convert unix string start time into time.Time object
131128 unixStartTime , err := strconv .ParseInt (occurrencePattern .OccurrenceID , 10 , 64 )
132129 if err != nil {
133- logger .With (errKey , err , "meeting_id" , meeting .ID , "recurrence_occurrence_id" , occurrencePattern .OccurrenceID , "recurrence_start_time" , occurrencePattern .StartTime ).ErrorContext (ctx , "failed to parse recurrence start_time" )
134- return nil , err
130+ return nil , fmt .Errorf ("failed to convert recurrence start time %s to int: %w" , occurrencePattern .OccurrenceID , err )
135131 }
136132 recStartTime := time .Unix (unixStartTime , 0 )
137133 recStartTime , err = timeInLocation (recStartTime , meeting .Timezone )
@@ -142,8 +138,7 @@ func calculateOccurrences(ctx context.Context, meeting meetingInput, pastOccurre
142138 // Get occurrences based on reccurrence pattern and start time
143139 occurrences , err := getRRuleOccurrences (recStartTime , meeting .Timezone , occurrencePattern .Recurrence , nil )
144140 if err != nil {
145- logger .With (errKey , err , "meeting_id" , meeting .ID , "start_time" , recStartTime , "recurrence_rrule" , occurrencePattern .Recurrence ).ErrorContext (ctx , "failed to get recurrence rule" )
146- return nil , err
141+ return nil , fmt .Errorf ("failed to get recurrence rule: %w" , err )
147142 }
148143 occurrencesInLog := occurrences
149144 // only show the first 100 occurrences to avoid spamming the logs
@@ -201,8 +196,7 @@ func calculateOccurrences(ctx context.Context, meeting meetingInput, pastOccurre
201196 currentAgenda = updatedOcc .Agenda
202197 unixStartTime , err := strconv .ParseInt (updatedOcc .NewOccurrenceID , 10 , 64 )
203198 if err != nil {
204- logger .With (errKey , err , "meeting_id" , meeting .ID , "occurrence" , updatedOcc ).ErrorContext (ctx , "failed to parse updated occurrence start_time" )
205- return nil , err
199+ return nil , fmt .Errorf ("failed to convert updated occurrence start time %s to int: %w" , updatedOcc .NewOccurrenceID , err )
206200 }
207201 currentStartTime = time .Unix (unixStartTime , 0 ).In (location )
208202 logger .With ("meeting_id" , meeting .ID , "current_start_time" , currentStartTime , "occurrence" , updatedOcc ).DebugContext (ctx , "current start time changed" )
@@ -233,8 +227,7 @@ func calculateOccurrences(ctx context.Context, meeting meetingInput, pastOccurre
233227 // Skip past occurrences if no past occurrences are expected
234228 unixStartTime , err := strconv .ParseInt (updatedOcc .NewOccurrenceID , 10 , 64 )
235229 if err != nil {
236- logger .With (errKey , err , "meeting_id" , meeting .ID , "occurrence_id" , o .Unix (), "updated_occ" , updatedOcc ).ErrorContext (ctx , "failed to parse updated occurrence start_time" )
237- return nil , err
230+ return nil , fmt .Errorf ("failed to convert updated occurrence start time %s to int: %w" , updatedOcc .NewOccurrenceID , err )
238231 }
239232
240233 // If updated occurrence does not have a duration, use meeting duration
@@ -441,8 +434,7 @@ func getRRule(reccurrence ZoomMeetingRecurrence, endTime *time.Time) (string, er
441434 reccurrence .EndTimes = "0"
442435 t , err := time .Parse (time .RFC3339 , reccurrence .EndDateTime )
443436 if err != nil {
444- logger .With (errKey , err , "recurrence" , reccurrence ).Error ("error parsing recurrence end_date_time" )
445- return "" , err
437+ return "" , fmt .Errorf ("failed to parse recurrence end_date_time %s: %w" , reccurrence .EndDateTime , err )
446438 }
447439 rrule .WriteString (fmt .Sprintf ("UNTIL=%s;" , t .Format ("20060102T150405Z" )))
448440 }
0 commit comments