do not throw exception if profile doesn't exist

This commit is contained in:
Milos Kozak 2021-10-20 15:57:07 +02:00
parent eb8a83d776
commit c966dfda13

View file

@ -154,8 +154,7 @@ class ProfileFunctionImplementation @Inject constructor(
}
override fun createProfileSwitch(durationInMinutes: Int, percentage: Int, timeShiftInHours: Int): Boolean {
val profile = repository.getPermanentProfileSwitch(dateUtil.now())
?: throw InvalidParameterSpecException("No active ProfileSwitch")
val profile = repository.getPermanentProfileSwitch(dateUtil.now()) ?: return false
val profileStore = activePlugin.activeProfileSource.profile ?: return false
val ps = buildProfileSwitch(profileStore, profile.profileName, durationInMinutes, percentage, 0, dateUtil.now())
val validity = ProfileSealed.PS(ps).isValid(