Re: [akka-user] Re: Debugging marshalling implicits
Thanks. It appears to be the absence of an Either marshaller ( Result[T] is an alias for Either[APIError,T] ) Is that something that was available in Spray, but not in Akka HTTP ? I see this got merged: https://github.com/akka/akka/pull/20274 but it's an Unmarshaller. On Tue, Sep 20, 2016 at 3:18 AM, 'Johannes Rudolph' via Akka User List < akka-user@googlegroups.com> wrote: > Hi, > > On Tuesday, September 13, 2016 at 4:26:55 PM UTC+2, rrodseth wrote: > > Is this the right way to debug the missing conversion? > > val prm = implicitly[Future[PimpedResult[(StatusCode, > Result[StatusDTO])]] => ToResponseMarshallable] > > > Try > > implicitly[ToResponseMarshaller[Future[PimpedResult[(StatusCode, > Result[StatusDTO])]]] > > > then > > > implicitly[ToResponseMarshaller[PimpedResult[(StatusCode, > Result[StatusDTO])]] > > > then > > implicitly[ToEntityMarshaller[Result[StatusDTO]]] // required by > APICustomMarshallers.statusMarshaller > > or just > > statusMarshaller[Result[StatusDTO]]] > > > and see which one still succeeds. Then you need to work back from the > simple ones to the more complex types, trying to get those to work. > > HTH > Johannes > > -- > >> 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. > -- >> 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.
[akka-user] Re: Debugging marshalling implicits
Hi, On Tuesday, September 13, 2016 at 4:26:55 PM UTC+2, rrodseth wrote: > Is this the right way to debug the missing conversion? > val prm = implicitly[Future[PimpedResult[(StatusCode, Result[StatusDTO])]] => ToResponseMarshallable] Try implicitly[ToResponseMarshaller[Future[PimpedResult[(StatusCode, Result[StatusDTO])]]] then implicitly[ToResponseMarshaller[PimpedResult[(StatusCode, Result[StatusDTO])]] then implicitly[ToEntityMarshaller[Result[StatusDTO]]] // required by APICustomMarshallers.statusMarshaller or just statusMarshaller[Result[StatusDTO]]] and see which one still succeeds. Then you need to work back from the simple ones to the more complex types, trying to get those to work. HTH Johannes -- >> 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.
[akka-user] Re: Debugging marshalling implicits
Bump. Is this the right way to debug the missing conversion? val prm = implicitly[Future[PimpedResult[(StatusCode, Result[StatusDTO])]] => ToResponseMarshallable] On Wed, Sep 7, 2016 at 8:43 PM, Richard Rodsethwrote: > Can anyone help me with this please? > I have the following in my route: > > val result = (requestHandler ? RequestHandler.AskForStatus). > mapTo[PimpedResult[(StatusCode, Result[StatusDTO])]] > > onSuccess(result) { > case _ => complete(result) > } > > The mapTo is really just to assist my debugging. The result could be a > Result[StatusDTO] or a PimpedResult. > Anyway, I get the following error on the complete call: > > type mismatch; found : > scala.concurrent.Future[PimpedResult[(akka.http.scaladsl.model.StatusCode, > Result[StatusDTO])]] (which expands to) scala.concurrent.Future[ > PimpedResult[(akka.http.scaladsl.model.StatusCode, > scala.util.Either[APIError,StatusDTO])]] required: akka.http.scaladsl. > marshalling.ToResponseMarshallable > > I added the following after the mapTo: > > val prm = implicitly[Future[PimpedResult[(StatusCode, > Result[StatusDTO])]] => ToResponseMarshallable] > > and that line gets this error: > > Multiple markers at this line: > > not enough arguments for method implicitly: (implicit e: > scala.concurrent.Future[PimpedResult[(akka.http.scaladsl.model.StatusCode, > Result[StatusDTO])]] ⇒ akka.http.scaladsl.marshalling. > ToResponseMarshallable)scala.concurrent.Future[PimpedResult[(akka.http.scaladsl.model.StatusCode, > Result[StatusDTO])]] ⇒ akka.http.scaladsl.marshalling.ToResponseMarshallable. > Unspecified value parameter e. > No implicit view available from scala.concurrent.Future[ > PimpedResult[(akka.http.scaladsl.model.StatusCode, Result[StatusDTO])]] ⇒ > akka.http.scaladsl.marshalling.ToResponseMarshallable. > > Here is the custom marshaller. I know it's in scope because the > errorMarshaller works in the case where the response is Result[StatusDTO] > rather than PimpedResult > > // See https://bitbucket.org/binarycamp/spray-contrib/src > trait APICustomMarshallers { > > implicit def errorMarshaller[T]( > implicit translator: ErrorTranslator[T], > statusCodeMapper: ErrorToStatusCodeMapper, > m: ToEntityMarshaller[T]): ToResponseMarshaller[APIError] = { > > val base = PredefinedToResponseMarshallers. > fromStatusCodeAndHeadersAndValue > val result = base.compose { > error: APIError => > (statusCodeMapper.orElse(ErrorToStatusCodeMapper.Default)(error), > DefaultHttpHeaders.NoCacheHeaders, translator(error)) > } > result > } > > implicit def statusMarshaller[T](implicit m: ToEntityMarshaller[T]): > ToResponseMarshaller[PimpedResult[(StatusCode, T)]] = { > val base = PredefinedToResponseMarshallers. > fromStatusCodeAndHeadersAndValue // Needs the entity marshaller > val result = base.compose { > pimpedResult: PimpedResult[(StatusCode, T)] => > pimpedResult.result match { > case Right(response) => (response._1, > DefaultHttpHeaders.NoCacheHeaders, > response._2) > case _ => throw new RuntimeException("StatusMarshaller > got invalid PimpedResult") > } > } > result > } > } > > Thanks for any help. > > > > > -- >> 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.