Skip to content

Commit cab2e76

Browse files
authored
Merge pull request #36 from xuwei-k/None-get
avoid "java.util.NoSuchElementException: None.get"
2 parents 5eec152 + 9fc0085 commit cab2e76

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/main/scala/gitbucket/gist/controller/GistController.scala

+12-8
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,18 @@ trait GistControllerBase extends ControllerBase {
446446
html.list(Some(GistUser(userName, fullName)), gists, page, page * Limit < result._2)
447447
}
448448
case Some(repoName) => {
449-
val gist = getGist(userName, repoName).get
450-
if(gist.mode == "PRIVATE"){
451-
context.loginAccount match {
452-
case Some(x) if(x.userName == userName) => _gistDetail(gist, userName, repoName, revision)
453-
case _ => Unauthorized()
454-
}
455-
} else {
456-
_gistDetail(gist, userName, repoName, revision)
449+
getGist(userName, repoName) match {
450+
case Some(gist) =>
451+
if(gist.mode == "PRIVATE"){
452+
context.loginAccount match {
453+
case Some(x) if(x.userName == userName) => _gistDetail(gist, userName, repoName, revision)
454+
case _ => Unauthorized()
455+
}
456+
} else {
457+
_gistDetail(gist, userName, repoName, revision)
458+
}
459+
case None =>
460+
NotFound()
457461
}
458462
}
459463
}

0 commit comments

Comments
 (0)