Hi Jack,
please don't double post questions to multiple forums at the same time, it
makes tracking if something is resolved or not yet much harder for us.
Or post the solution on the relevant cross-posted threads once you have
found it, so others can benefit from fiding it, thanks a lot in advance!

This was answered on StackOverflow:
http://stackoverflow.com/questions/32969554/mapinnerroute-is-not-working

def completeWithUserAwareException(user: User) =
  handleExceptions(
    ExceptionHandler {
      case NonFatal(ex) => failWith(new ExceptionWithUser(user, 0, ex))
    })


On Tue, Oct 6, 2015 at 8:33 PM, Jack Daniels <rus...@walkmind.com> wrote:

> I'm trying to create route that would wrap caught exception into my
> exception that carries user object of logged-in user. Ideally I prefer to
> put that information into ContextRequest in order to use it in my
> ExceptionHandler but it's immutable.
>
>
> I concluded that the right way to do it is to use mapInnerRoute as
> described in this example
> <http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0/scala/http/routing-dsl/directives/basic-directives/mapInnerRoute.html#Example>
> .
>
>
> def completeWithUserAwareException(user: User) =
>   mapInnerRoute { route =>
>     ctx =>
>       try {
>         route(ctx)
>       } catch {
>         case ex: Throwable =>
>           ctx.fail(new ExceptionWithUser(user, 0, ex))
>       }
>   }
>
>
> which I use like this
>
>
> val authenticatedRoutes = myAuthorization { user =>
>     completeWithUserAwareException(user) {
>     pathPrefix("admin") {
>       (get & path("plugins")) {
>           complete {
>             ""
>           }
>       }
>     }
>   }}
>
>
> Content of completeWithUserAwareException is never invoked. I suspect it
> has something to do with dynamic nature of outer route.
>
>
> How can I achieve my goal of passing user context information to exception
> handler ?
>
> SO question is here :
> http://stackoverflow.com/questions/32969554/mapinnerroute-is-not-working
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Cheers,
Konrad 'ktoso' Malawski
Akka <http://akka.io/> @ Typesafe <http://typesafe.com/>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to