Aha. Did not realize there was a separate method. Thanks a lot for your help!
Best, Patrick On Wednesday, January 4, 2017 at 1:15:41 PM UTC-5, Konrad Malawski wrote: > > 5* parameter :) > > -- > Konrad `ktoso` Malawski > Akka <http://akka.io> @ Lightbend <http://lightbend.com> > > On 4 January 2017 at 19:13:37, Patrick O'Reilly ([email protected] > <javascript:>) wrote: > > Hi Konrad, > > Thanks for the prompt reply. I've tried the StatusCodes.custom call with a > non-standard status code but it throws the following exception: > > Exception in thread "main" java.lang.IllegalArgumentException: Can't > register status code in non-standard region > at akka.http.scaladsl.model.StatusCodes$.custom(StatusCode.scala:92) > at AkkaHttp2$.delayedEndpoint$AkkaHttp2$1(AkkaHttp2.scala:47) > at AkkaHttp2$delayedInit$body.apply(AkkaHttp2.scala:16) > at scala.Function0$class.apply$mcV$sp(Function0.scala:34) > at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) > at scala.App$$anonfun$main$1.apply(App.scala:76) > at scala.App$$anonfun$main$1.apply(App.scala:76) > at scala.collection.immutable.List.foreach(List.scala:381) > at > scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35) > at scala.App$class.main(App.scala:76) > at AkkaHttp2$.main(AkkaHttp2.scala:16) > at AkkaHttp2.main(AkkaHttp2.scala) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) > > It seems StatusCodes.custom specifically doesn't allow codes outside the > normal range: > > def custom(intValue: Int, reason: String, defaultMessage: String = ""): > StatusCode = > if (100 to 199 contains intValue) Informational(intValue)(reason, > defaultMessage) > else if (200 to 299 contains intValue) Success(intValue)(reason, > defaultMessage) > else if (300 to 399 contains intValue) Redirection(intValue)(reason, > defaultMessage, defaultMessage) > else if (400 to 499 contains intValue) ClientError(intValue)(reason, > defaultMessage) > else if (500 to 599 contains intValue) ServerError(intValue)(reason, > defaultMessage) > else throw new IllegalArgumentException("Can't register status code in > non-standard region") > > Best, > Patrick > > > On Wednesday, January 4, 2017 at 12:49:21 PM UTC-5, Konrad Malawski wrote: >> >> Everything is configurable :-) >> >> I see we missed to document that setting. We documented how to do it for >> custom media types here: >> http://doc.akka.io/docs/akka-http/current/scala/http/routing-dsl/directives/method-directives/extractMethod.html#custom-http-method >> >> Which is basically the same process you'll need to do for the status code: >> >> val parserSettings = >> ParserSettings(system).withCustomStatusCodes(StatusCodes.custom(666, >> "BadStatusCode", "The number of the beast", false, false)) >> >> val serverSettings = >> ServerSettings(system).withParserSettings(parserSettings) >> >> val binding = Http().bindAndHandle(routes, host, port, settings = >> serverSettings) >> >> >> I'll add that to the docs. >> >> Happy hakking >> >> -- >> Konrad `ktoso` Malawski >> Akka <http://akka.io> @ Lightbend <http://lightbend.com> >> >> On 4 January 2017 at 18:46:08, Patrick O'Reilly ([email protected]) >> wrote: >> >> Hi, >> >> We're using Akka HTTP client to consume a remote API. This API however is >> returning non-standard status codes in the 600's which cannot be parsed by >> Akka. akka.http.ParserSettings.withCustomStatusCodes only allow valid >> 100-599 codes. Does anyone have a solution to this problem? The exception >> thrown is an illegal response status but the exception has no details on >> the actual status code. >> >> Thanks, >> Patrick >> >> -- >> >>>>>>>>>> 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 [email protected]. >> To post to this group, send email to [email protected]. >> 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 [email protected] <javascript:>. > To post to this group, send email to [email protected] > <javascript:>. > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
