Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8794215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:13:19+00:00 2026-06-13T23:13:19+00:00

I just cannot figure out a way to google this. I have, for example,

  • 0

I just cannot figure out a way to google this. I have, for example, code like this:

import dispatch._
object Main extends App {

  val svc = url("http://www.php.net/license")
  val src:Promise[String] = Http(svc OK as.String) recover {
    case StatusCode(301) => "got the 301, now where the heck should I go?"
    case error => "caught error:" + error.toString
  }

  println(src())
}

From the dispatch package, recover takes a PartialFunction[Throwable,A] where A ends up being a String in my case. That url always returns 301, presumably with a message telling me where I should go instead. But in pattern matching on it, how do I access the plethora of methods that are inherited by statuscode that could give me an idea of what went wrong?

In haskell I’d do it like this:

case x of
  sc@StatusCode(301) -> getMessage(sc)
  error -> ...

If it is not possible to get the original object in scala, is there some way I could have written this code so that it would have worked?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:13:21+00:00Added an answer on June 13, 2026 at 11:13 pm

    I’m sorry I’m a complete idiot. I didn’t even think to try this even after writing my haskell solution:

    case sc@StatusCode(301) => sc.getMessage
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a very weird problem in chrome I just cannot figure out!
I just cannot figure this out, it looks really simple but I'm relatively new
I just cannot seem to figure this out. I need another set of eyes.
In the code below, I cannot figure out a way of passing a member
I am pulling my hair out because I just cannot figure this out. I
I have looked everywhere for this and just cannot find the answer. I have
I have this problem and i just cannot find a solution to it. I
I have a problem that I really cannot figure out how to solve. I
I know how to do this in sql, but for c#..I cannot figure out
I am really struggling to figure out a way to do this. Say I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.