Skip to content

Commit f5ad476

Browse files
committed
Refactoring complex source code
1 parent 3e76f86 commit f5ad476

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package gitbucket.monitoring.controllers
22

3+
import scala.util.Try
34
import gitbucket.monitoring.services.{LogBack, GitBucketLog}
45
import gitbucket.monitoring.information.logs._
56

@@ -16,19 +17,15 @@ trait LogController extends MonitoringControllerBase {
1617
val defaultSettings = GitBucketLog.getDefaultSettings
1718
val lineNum = request.getParameter("lines")
1819

19-
if (Option(lineNum) != None){
20-
try {
21-
val n = lineNum.toInt
22-
if (n > defaultSettings.displayLimitLines) {
23-
html.gitbucketlog(defaultSettings, os.getLog(defaultSettings.displayLimitLines));
24-
} else {
25-
html.gitbucketlog(defaultSettings, os.getLog(n));
26-
}
27-
} catch {
28-
case e: Exception => html.gitbucketlog(defaultSettings, os.getLog());
20+
if (Try(lineNum.toInt).toOption != None){
21+
val n = lineNum.toInt
22+
if (n > defaultSettings.displayLimitLines) {
23+
html.gitbucketlog(defaultSettings, os.getLog(defaultSettings.displayLimitLines));
24+
} else {
25+
html.gitbucketlog(defaultSettings, os.getLog(n));
2926
}
3027
} else {
31-
html.gitbucketlog(defaultSettings, os.getLog());
28+
html.gitbucketlog(defaultSettings, os.getLog(defaultSettings.defaultDisplayLines));
3229
}
3330
})
3431
}

0 commit comments

Comments
 (0)