value isDefinedAt不是play.api.mvc.SimpleResult的成员

时间:2013-11-13 09:43:35

标签: scala playframework try-catch scala-2.10 playframework-2.2

以下代码给出了错误,我不知道原因是什么,以及如何删除此错误,告诉我我做错了什么。

def members(id:String,name:String) = Action { implicit request =>
    try{
        session.get("userId").map{user=>
            val Data =NewModel.getInfo(id)
            val userId=session.get("userId").get
            if(userId==Data.createdBy){
                Ok(html.groupMembers(Data,"mainAdmin"))
            }else{try{
                    val admin=NewModel.admin(id,userId);
                        Ok(html.members(Data,"subAdmin"))
                 }catch{
                        try{
                            val member=NewModel.member(id,userId)
                                Ok(html.members(Data,"member"));
                        }catch{
                          if(Data.privacy!="secret")
                            Ok(html.members(Data,"outsider"))
                          else
                            Ok(html.noPageFound())
                        }
                 }   
            }   
        }.getOrElse{
            Redirect("/")
        }
    }catch{
        case e=>
          println(e)
          Ok(html.onError())
    }
    }//end groupSetting

1 个答案:

答案 0 :(得分:8)

在每个catch块中使用它

catch{
    case e=>
      //code
}

编辑:

catch{
    case e:Exception=>
      //code
}