com.nrinaudo.fetch

Status

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
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Status(code: Int)

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

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

  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def finalize(): Unit

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

    Definition Classes
    AnyRef → Any
  12. def isClientError: Boolean

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

  13. def isError: Boolean

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

  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. def isRedirection: Boolean

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

  16. def isServerError: Boolean

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

  17. def isSuccess: Boolean

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

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

    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

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

    Definition Classes
    AnyRef
  22. def toString(): String

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

    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)
    }
  24. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped