Class/Object

com.nrinaudo.fetch

Status

Related Docs: object Status | package fetch

Permalink

case class Status(code: Int) extends Product with Serializable

Represents an HTTP status code, as defined in RFC 2616.

This class and its companion objects provide various extraction helpers to ease pattern matching. For example:

val res: Response[ResponseEntity] = ???

res.status match {
  case Status.Success(_) => println("Success")
  case _                 => println("Not success")
}

It's also possible to pattern match directly on instances of Response, which can be useful when mapping on requests:

val res: Request[Response[ResponseEntity]] = ???

res map {
  // Match on the 2xx group
  case res @ Status.Success(_)       => println("Success: " + res.body.as[String])
  // Match on HTTP 500
  case Status.InternalServerError(_) => println("Internal server error")
  // Match on everything else
  case _                             => println("Something else entirely")
}

See the companion object for known status codes.

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Status
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Status(code: Int)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. val code: Int

    Permalink
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def isClientError: Boolean

    Permalink

    Checks whether the status is a client error (4xx).

  11. def isError: Boolean

    Permalink

    Checks whether the status is an error (4xx and 5xx).

  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. def isRedirection: Boolean

    Permalink

    Checks whether the status is a redirection (3xx).

  14. def isServerError: Boolean

    Permalink

    Checks whether the status is a server error (5xx).

  15. def isSuccess: Boolean

    Permalink

    Checks whether the status is a client error (2xx).

  16. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  20. def toString(): String

    Permalink
    Definition Classes
    Status → AnyRef → Any
  21. def unapply[T](res: Response[T]): Option[Status]

    Permalink

    Allows instances of Status to be used as extractors for Response.

    Allows instances of Status to be used as extractors for Response.

    For example:

    val req: Request[Response[ResponseEntity]] = ???
    
    req.map {
      case res @ Status.Ok(_) => res.body.as[String]
      case Status(status)     => throw new Exception("Unexpected status: " + status)
    }
  22. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped