From 9fc0085b4fbea19ef0d27031be2a7f455a4636e6 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Mon, 12 Dec 2016 17:57:13 +0900 Subject: [PATCH] avoid "java.util.NoSuchElementException: None.get" --- .../gist/controller/GistController.scala | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/scala/gitbucket/gist/controller/GistController.scala b/src/main/scala/gitbucket/gist/controller/GistController.scala index ed7af4e..99ec390 100644 --- a/src/main/scala/gitbucket/gist/controller/GistController.scala +++ b/src/main/scala/gitbucket/gist/controller/GistController.scala @@ -446,14 +446,18 @@ trait GistControllerBase extends ControllerBase { html.list(Some(GistUser(userName, fullName)), gists, page, page * Limit < result._2) } case Some(repoName) => { - val gist = getGist(userName, repoName).get - if(gist.mode == "PRIVATE"){ - context.loginAccount match { - case Some(x) if(x.userName == userName) => _gistDetail(gist, userName, repoName, revision) - case _ => Unauthorized() - } - } else { - _gistDetail(gist, userName, repoName, revision) + getGist(userName, repoName) match { + case Some(gist) => + if(gist.mode == "PRIVATE"){ + context.loginAccount match { + case Some(x) if(x.userName == userName) => _gistDetail(gist, userName, repoName, revision) + case _ => Unauthorized() + } + } else { + _gistDetail(gist, userName, repoName, revision) + } + case None => + NotFound() } } }