java - error trying to get errors with scala Try function -


i'm trying catch errors try , i'm getting error dont know why, code:

class application extends controller {    val ds: datasource = csvdatasource   val purchaseds = purchaseinfo.fromdatasource(ds)_     def index = action { implicit request =>     ok(views.html.index())   }    def redirecttoindex = action {     redirect(routes.application.index)   }    case class csvuploaddata(clienturl: string)   val csvuploadform = form(     mapping(       "clienturl" -> nonemptytext)(csvuploaddata.apply)(csvuploaddata.unapply))    def uploadcsv = action.async(parse.multipartformdata) { implicit request =>     csvuploadform.bindfromrequest.fold(       formwitherrors => {         future {           redirect(routes.application.index).flashing(             "error" -> formwitherrors.error("clienturl").get.message)         }       },       userdata => {         request.body.file("csvfile").fold(future {           redirect(routes.application.index).flashing(             "error" -> "missing csv file").withsession(request.session)         }) { formfile =>           import java.io.file           val filename = formfile.filename           future {             val file = formfile.ref.file             val purchaseinfos = purchaseds(file)              val t = try {               val driver: webdriver = new firefoxdriver               val actions: actionshmrc = new actionshmrc(driver, userdata.clienturl)                val results = actions.insertdata(purchaseinfos)               results.filter(_._2.isfailure)             }             t match {               case success(failures) =>                 val failedmsg = if (failures.nonempty) failures.mkstring("the following rows failed: [",",","]") else ""                 redirect(routes.application.index).flashing(                 "success" -> s"the file '$filename' automation successfuly.\n$failedmsg")               case failure(e) =>                 println(e)                 redirect(routes.application.index).flashing(                 "error" -> s"the file '$filename' automation failed.")             }           }         }       })   } } 

actionshmrc method:

def insertdata(purchaseinfos: seq[purchaseinfo]) = {     login()     purchaseinfos.map { case purchaseinfo =>       (purchaseinfo, try(doactions(purchaseinfo)))     }     println("done insertdata function")   } 

those lines colored red (so there wrong them) , don't understand why...

filter(_._2

nonempty

mkstring

if know maybe going on allot, thanksss

insertdata, written returns unit. unit not have filter method.

i suggest adding return type method (and public method), compiler give error messages closer error is.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -