{"action":"created","issue":{"url":"https://api.github.com/repos/ShunsukeTadokoro/code-snip/issues/4","labels_url":"https://api.github.com/repos/ShunsukeTadokoro/code-snip/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/ShunsukeTadokoro/code-snip/issues/4/comments","events_url":"https://api.github.com/repos/ShunsukeTadokoro/code-snip/issues/4/events","html_url":"https://github.com/ShunsukeTadokoro/code-snip/issues/4","id":103724946,"number":4,"title":"getOrElseでelseだった場合","user":{"login":"takezoe","id":1094760,"avatar_url":"https://avatars.githubusercontent.com/u/1094760?v=3","gravatar_id":"","url":"https://api.github.com/users/takezoe","html_url":"https://github.com/takezoe","followers_url":"https://api.github.com/users/takezoe/followers","following_url":"https://api.github.com/users/takezoe/following{/other_user}","gists_url":"https://api.github.com/users/takezoe/gists{/gist_id}","starred_url":"https://api.github.com/users/takezoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takezoe/subscriptions","organizations_url":"https://api.github.com/users/takezoe/orgs","repos_url":"https://api.github.com/users/takezoe/repos","events_url":"https://api.github.com/users/takezoe/events{/privacy}","received_events_url":"https://api.github.com/users/takezoe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"ShunsukeTadokoro","id":2328540,"avatar_url":"https://avatars.githubusercontent.com/u/2328540?v=3","gravatar_id":"","url":"https://api.github.com/users/ShunsukeTadokoro","html_url":"https://github.com/ShunsukeTadokoro","followers_url":"https://api.github.com/users/ShunsukeTadokoro/followers","following_url":"https://api.github.com/users/ShunsukeTadokoro/following{/other_user}","gists_url":"https://api.github.com/users/ShunsukeTadokoro/gists{/gist_id}","starred_url":"https://api.github.com/users/ShunsukeTadokoro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShunsukeTadokoro/subscriptions","organizations_url":"https://api.github.com/users/ShunsukeTadokoro/orgs","repos_url":"https://api.github.com/users/ShunsukeTadokoro/repos","events_url":"https://api.github.com/users/ShunsukeTadokoro/events{/privacy}","received_events_url":"https://api.github.com/users/ShunsukeTadokoro/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-08-28T14:08:46Z","updated_at":"2015-09-02T12:49:30Z","closed_at":null,"body":"コントローラで\r\n```scala\r\nval userId = User.selectUserBySession(rs).map(u => u._1).getOrElse(\"\")\r\n```\r\nみたいにしている箇所がありますが、この場合であれば\r\n```scala\r\nUser.selectUserBySession(rs).map(u => u._1).map { userId =>\r\n  ...\r\n}.getOrElse NotFound\r\n```\r\nなどのようにエラーを返すべきかと。コントローラ全体的に見直してみてください。\r\n"},"comment":{"url":"https://api.github.com/repos/ShunsukeTadokoro/code-snip/issues/comments/137063159","html_url":"https://github.com/ShunsukeTadokoro/code-snip/issues/4#issuecomment-137063159","issue_url":"https://api.github.com/repos/ShunsukeTadokoro/code-snip/issues/4","id":137063159,"user":{"login":"ShunsukeTadokoro","id":2328540,"avatar_url":"https://avatars.githubusercontent.com/u/2328540?v=3","gravatar_id":"","url":"https://api.github.com/users/ShunsukeTadokoro","html_url":"https://github.com/ShunsukeTadokoro","followers_url":"https://api.github.com/users/ShunsukeTadokoro/followers","following_url":"https://api.github.com/users/ShunsukeTadokoro/following{/other_user}","gists_url":"https://api.github.com/users/ShunsukeTadokoro/gists{/gist_id}","starred_url":"https://api.github.com/users/ShunsukeTadokoro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShunsukeTadokoro/subscriptions","organizations_url":"https://api.github.com/users/ShunsukeTadokoro/orgs","repos_url":"https://api.github.com/users/ShunsukeTadokoro/repos","events_url":"https://api.github.com/users/ShunsukeTadokoro/events{/privacy}","received_events_url":"https://api.github.com/users/ShunsukeTadokoro/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T12:49:30Z","updated_at":"2015-09-02T12:49:30Z","body":"コントローラー内で`.getOrElse(\"\")`などとしていたところを、\r\n```\r\nUser.selectUserBySession(rs).map(u => u._1).map { userId =>\r\n      Ok(Json.toJson(Favorite.selectFavoriteList(userId)))\r\n}.getOrElse(NotFound(Json.obj(\"result\" -> \"notFound\")))\r\n```\r\nのように修正しました。\r\nきちんとエラーが返せるようになっただけでなく、コードの意図が明確になり読みやすくなったように感じます！ありがとうございます！"}}