Skip to content

System.DevideByZeroException: Attempted to devide by zero #456

@Zenith-Mx

Description

@Zenith-Mx

When trying to synchronize Outlook events to Nextcloud via CalDavSynchronizer, one event caused this error which always pops up after every synchronization attempt.

Image

The issue occurs within the AddMasterEvent(IICalendar calendar) method in the CalDavSynchronizer.Implementation.Events.EventEntityManager class. I would suggest that it's the following part of the code which causes this error, since it's the only division I was able to find directly within the AddMasterEvent method:

var intervalInDays = GreatestCommonDivisor(sortedExceptionsWithDistance.Select(d => d.DistanceFromMasterInDays));

var numberOfEceptions = sortedExceptionsWithDistance.Last().DistanceFromMasterInDays / intervalInDays + 1;

It seems like it's possible that intervalInDays + 1 is equal to zero, causing a System.DevideByZeroException.

Implementing handling for this problem would be greatly appreciated, as the only way I found to fix the error popup during synchronization is to fully remove the event.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions