S.params throws exception for a non-existent parameter
From the list:
Hi,
I have been having trouble reading a list of HTTP parameters with the
same name that may or may not exist. If I call S.params("nn") and "nn"
doesn't exist, it throws a NoSuchElementException: "key not found". I
was expecting an empty List.
The code for S.params is
def params(n: String): List[String] = request.map(_.params(n)).openOr
(Nil)
Shouldn't it be something like:
def params(n: String): List[String] = request.map(_.params.getOrElse
(n,Nil)).openOr(Nil)
Hi,
I have been having trouble reading a list of HTTP parameters with the
same name that may or may not exist. If I call S.params("nn") and "nn"
doesn't exist, it throws a NoSuchElementException: "key not found". I
was expecting an empty List.
The code for S.params is
def params(n: String): List[String] = request.map(_.params(n)).openOr
(Nil)
Shouldn't it be something like:
def params(n: String): List[String] = request.map(_.params.getOrElse
(n,Nil)).openOr(Nil)
Leave a comment
on 2010-02-06 13:47 *
By github.importer
Imported from GitHub: http://github.com/dpp/liftweb/issues/22/find