fix(#74): mark unparseable cron expressions instead of silently returning raw
Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
11d97a2d5f
commit
6375e3fa1d
1 file changed
+6
-1
@@ -1,5 +1,7 @@
|
|||||||
package com.m57.hermescontrol.util
|
package com.m57.hermescontrol.util
|
||||||
|
|
||||||
|
import com.m57.hermescontrol.BuildConfig
|
||||||
|
|
||||||
object CronExpressionFormatter {
|
object CronExpressionFormatter {
|
||||||
fun cronToHumanReadable(schedule: String): String {
|
fun cronToHumanReadable(schedule: String): String {
|
||||||
val clean = schedule.trim().replace("\\s+".toRegex(), " ")
|
val clean = schedule.trim().replace("\\s+".toRegex(), " ")
|
||||||
@@ -150,7 +152,10 @@ object CronExpressionFormatter {
|
|||||||
// Fallback
|
// Fallback
|
||||||
return schedule
|
return schedule
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
return schedule
|
if (BuildConfig.DEBUG) {
|
||||||
|
android.util.Log.w("CronExpressionFormatter", "Failed to parse cron: $schedule", e)
|
||||||
|
}
|
||||||
|
return "Raw: $schedule"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user