Date: Sat, 13 Oct 2012 09:11:23 -0700 (PDT) From: bg To: liftweb@googlegroups.com Message-Id: <1d76c5a6-b8c9-45db-af9d-7e15c511ff81@googlegroups.com> In-Reply-To: References: <39e69b5a-e65c-47f7-9fb2-414d6229c521@googlegroups.com> Subject: Re: [Lift] Using a Box / Failure and how to set HTTP status code MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_2277_5649813.1350144683724" ------=_Part_2277_5649813.1350144683724 Content-Type: multipart/alternative; boundary="----=_Part_2278_8848246.1350144683731" ------=_Part_2278_8848246.1350144683731 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sorry guys - I'm still not quite understanding what I need to. David - as I read your example - the error message is still being created after a Failure is returned. I would like to have "userDoes" as a helper function which checks multiple conditions, and the appropriate error can be extracted from the Failure that is returned. I tried the below - but get a compilation error for { allowed <- resourceAction.userDoes("addConnection") ?~ _.msg ~> 407 } yield { ... missing parameter type for expanded function ((x$4) => resourceAction.userDoes("addConnection").$qmark$tilde(x$4.msg).$tilde$greater(407)) [error] allowed <- resourceAction.userDoes("addConnection") ?~ _.msg ~> 407 > On Fri, Oct 12, 2012 at 7:15 AM, bg >wrote: > >> Hi guys, >> >> How would I get the message in the "Failure" using a for comprehension. >> >> In my first post - userAllowed functions does some checking, and has >> different messages for different scenarios? >> >> for ( extracted <- SomeValue ?~ "param failure error message" # instead >> of writing this message, can I look at the Failure and get the message >> returned with it? # ~> 401) yield extracted >> >> >> On Friday, October 12, 2012 10:09:19 AM UTC+1, maarten wrote: >>> >>> This returns "extracted" wrapped in a Box[SomeType] assuming that >>> SomeValue is if Box[SomeType]: >>> >>> for ( extracted <- SomeValue ?~ "param failure error message" ~> 401) >>> yield extracted >>> >>> Of course you can add processing logic in the yield using a helper >>> function (so you get yield f(extracted)) >>> >>> Does this help? >>> >>> --Maarten >>> >>> On Friday, October 12, 2012, Naftoli Gugenheim wrote: >>> >>>> >>>> On Mon, Oct 8, 2012 at 5:49 PM, David Pollak < >>>> feeder.of.the.be...@gmail.com**> wrote: >>>> >>>>> Please do not use pattern matching, please use for comprehensions. >>>>> >>>> >>>> Why? And, how do you handle the Failure case? >>>> >>>> -- >>>> -- >>>> Lift, the simply functional web framework: http://liftweb.net >>>> Code: http://github.com/lift >>>> Discussion: http://groups.google.com/**group/liftweb >>>> Stuck? Help us help you: https://www.assembla.com/wiki/** >>>> show/liftweb/Posting_example_**code >>>> >>>> >>>> >>>> >>> -- >> -- >> Lift, the simply functional web framework: http://liftweb.net >> Code: http://github.com/lift >> Discussion: http://groups.google.com/group/liftweb >> Stuck? Help us help you: >> https://www.assembla.com/wiki/show/liftweb/Posting_example_code >> >> >> >> > > > > -- > Telegram, Simply Beautiful CMS https://telegr.am > Lift, the simply functional web framework http://liftweb.net > Follow me: http://twitter.com/dpp > Blog: http://goodstuff.im > > > ------=_Part_2278_8848246.1350144683731 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sorry guys - I'm still not quite understanding what I need to. 
David - as I read your example - the error message is still be= ing created after a Failure is returned. I would like to have "userDoes" as= a helper function which checks multiple conditions, and the appropriate er= ror can be extracted from the Failure that is returned. 
I tried the below - but get a compilation error

<= div>
for {
      allowed <- resourceAction.= userDoes("addConnection") ?~ _.msg ~> 407
    } yiel= d {
      ...
missing parameter type for= expanded function ((x$4) =3D> resourceAction.userDoes("addConnection").= $qmark$tilde(x$4.msg).$tilde$greater(407))
[error]     =   allowed <- resourceAction.userDoes("addConnection") ?~ _.msg ~>= ; 407


On Fri, Oct 12, 2012 at 7:15 AM, bg <brent...@gmail.com> wrote:
Hi guys,

How would I get = the message in the "Failure" using a for comprehension.

In my first post - userAllowed functions does some chec= king, and has different messages for different scenarios?

for ( extracted <- SomeValue ?~ "param failure error messag= e" # instead of writing this message, can I look at the Failure and get the= message returned with it? # ~> 401) yield extracted


On Friday, October 12, 2012 10:09:19 AM UTC+1,= maarten wrote:
This returns "extrac= ted" wrapped in a Box[SomeType] assuming that SomeValue is if Box[SomeType]= :

for ( extracted <- SomeValue ?~ "param failure error mess= age" ~> 401) yield extracted

Of course you can add processing logic in the yield usi= ng a helper function (so you get yield f(extracted))

Does this help?

--Maarten

On Friday, October 12, 2012, Naftoli Gugenheim wrote:

On Mon, Oct 8= , 2012 at 5:49 PM, David Pollak <feeder.of.the.bear= s...@gmail.com> wrote:
Please do not use pattern matching, ple= ase use for comprehensions.

Why? And, how do you handle the Failure case?

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.co= m/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/<= u>show/liftweb/Posting_example_code
 
 
 

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.co= m/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/<= wbr>show/liftweb/Posting_example_code
 
 
 



--
=
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framewo= rk http://liftweb.net<= div> Follow me: http://twit= ter.com/dpp
Blog: = http://goodstuff.im


------=_Part_2278_8848246.1350144683731-- ------=_Part_2277_5649813.1350144683724--