Skip to content

Commit 0d43dd6

Browse files
committed
Refactoring delete no need try-catch block
1 parent b17d45e commit 0d43dd6

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

src/main/scala/gitbucket/monitoring/services/operatingsystem/Linux.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ class Linux extends SystemInformation with MachineResources with ProcessInfo wit
1010
val ut = (Process("cat /proc/uptime") !!).split(" ")
1111
val dt = Time.secondsToDateTime(Rounding.ceil(BigDecimal(ut(0)),0).toInt)
1212
Right(UpTime(
13-
dt match {
14-
case Left(message) => (message)
15-
case Right(l) => (l.days.toString + " days " + l.hours.toString + " hours " + l.minutes.toString + " minutes ")
16-
},
13+
dt.days.toString + " days " + dt.hours.toString + " hours " + dt.minutes.toString + " minutes ",
1714
Process("uptime -s") !!
1815
))
1916
} catch {

src/main/scala/gitbucket/monitoring/utils/Calc.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@ object Time {
1919
minutes: Int
2020
)
2121

22-
def secondsToDateTime(seconds: Int): Either[String, DateTime] = {
23-
try {
24-
Right(DateTime(
22+
def secondsToDateTime(seconds: Int): DateTime = {
23+
DateTime(
2524
seconds / (60 * 60 * 24),
2625
((seconds / (60 * 60)) % 24) % 60,
2726
(seconds / 60) % 60
28-
))
29-
} catch {
30-
case e: Exception => Left(Message.error)
31-
}
27+
)
3228
}
3329
}

0 commit comments

Comments
 (0)