Hello,

I am building an application using Play 2.6 with Scala 2.12.3 and Akka 
2.5.4 Actors.

I am using the ask pattern in several places at it is documented at link 
below
https://www.playframework.com/documentation/2.6.x/ScalaAkka

The ask patten works well in all regartds except that I do not know how to 
integrate exception handling
into the pattern.  Specifically I want to manage the AskTimeoutException.  
The ask might not be answered because it depends on the success of 
dangerous operations ( file operations ).  I tried to code try catch but 
got complicated verbose compile errors I could not understand

For example: with this code:


def start_agent_processing( agent_name : String ) = Action.async            
           
    {
      implicit val timeout: Timeout = timeout_value.seconds
      try
      {
        val query = M_AddAgent( agent_name )
        ( speaker ? query).mapTo[M_AddAgentFinish_R].map
        {
          agent_disposition =>
          if( agent_disposition.error == false )
          {
            agent_start_result = AgentStart.Ok
            agent_start_validity = Error.NoneOccurred
            agent_error_location = Error.NoneOccurred
            agent_exception_type = Error.NoneOccurred
            agent_exception_cause = Error.NoneOccurred
          }
          else
          {
            agent_start_result = AgentStart.Problem
            agent_start_validity = Error.Occurred
            agent_error_location = agent_disposition.error_location
            agent_exception_type = agent_disposition.exception_type
            agent_exception_cause = agent_disposition.exception_cause
          }
          val content = Map( "[agent-start-result]" -> agent_start_result,
                             "[agent-name]" -> agent_name,
                             "[error]" -> agent_start_validity,
                             "[error-location]" -> agent_error_location,
                             "[exception-type]" -> agent_exception_type,
                             "[exception-cause]" -> agent_exception_cause,
                             "[action-menu]" -> menu )
          val html = paste( 
"public/templates/start_agent_processing.templ", content )
          Ok( html ).as( "text/html" )
        }
      }
      catch
      {
        case e : AskTimeoutException => println("exception")
      }
    }

produced the complier error list below

[info] Compiling 1 Scala source to 
/home/joe/Play/datafiles/Alfa/target/scala-2.12/classes ...
[error] /home/joe/Play/datafiles/Alfa/app/controllers/Alfa.scala:82:64: 
overloaded method value async with alternatives:
[error]   [A](bodyParser: play.api.mvc.BodyParser[A])(block: 
play.api.mvc.Request[A] => 
scala.concurrent.Future[play.api.mvc.Result])play.api.mvc.Action[A] <and>
[error]   (block: play.api.mvc.Request[play.api.mvc.AnyContent] => 
scala.concurrent.Future[play.api.mvc.Result])play.api.mvc.Action[play.api.mvc.AnyContent]
 
<and>
[error]   (block: => 
scala.concurrent.Future[play.api.mvc.Result])play.api.mvc.Action[play.api.mvc.AnyContent]
[error]  cannot be applied to (Any)
[error]     def start_agent_processing( agent_name : String ) = 
Action.async                       
[error]                                                                ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 16 s, completed Apr 2, 2018 8:26:18 PM

Does anyone insight and advice on how to integrate error handling into this 
style of using the ask pattern?

Thanks, Joe

-- 
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
>>>>>>>>>> 
>>>>>>>>>>      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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to