Skip to content

Commit

Permalink
issue-1438: make unapply private
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryAghedo committed Sep 13, 2024
1 parent e2a1bb2 commit fdd4c19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
7 changes: 5 additions & 2 deletions modules/core/src/smithy4s/http/RawErrorResponse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package smithy4s.http

case class RawErrorResponse(
import scala.annotation.nowarn

case class RawErrorResponse private (
private val codeField: Int,
private val headersField: Map[CaseInsensitive, Seq[String]],
private val bodyField: String,
Expand Down Expand Up @@ -84,7 +86,8 @@ object RawErrorResponse {
): RawErrorResponse =
new RawErrorResponse(code, headers, body, failedDecodeAttempt)

def unapply(response: RawErrorResponse): Option[
@nowarn
private def unapply(response: RawErrorResponse): Option[
(Int, Map[CaseInsensitive, Seq[String]], String, FailedDecodeAttempt)
] =
Some(
Expand Down
39 changes: 12 additions & 27 deletions modules/tests/src/smithy4s/tests/PizzaClientSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ import smithy4s.Timestamp
import weaver._
import smithy4s.http.CaseInsensitive
import smithy4s.http.RawErrorResponse
import smithy4s.http.FailedDecodeAttempt
import smithy4s.http.HttpPayloadError
import smithy4s.http.HttpDiscriminator
import smithy4s.http.FailedDecodeAttempt.DecodingFailure

abstract class PizzaClientSpec extends IOSuite {

Expand Down Expand Up @@ -121,27 +120,18 @@ abstract class PizzaClientSpec extends IOSuite {
.withHeaders(Header.Raw(CIString("X-Error-Type"), "NotFoundError")),
error => {
error match {
case RawErrorResponse(
code,
headers,
body,
FailedDecodeAttempt.DecodingFailure(
discriminator,
HttpPayloadError(path, expected, _)
)
) =>
expect(code == 404) &&
case e: RawErrorResponse =>
expect(e.code == 404) &&
expect(
headers == Map(
e.headers == Map(
CaseInsensitive("X-Error-Type") -> List("NotFoundError")
)
) &&
expect(body == "malformed body") &&
expect(e.body == "malformed body") &&
expect(
discriminator == HttpDiscriminator.NameOnly("NotFoundError")
e.failedDecodeAttempt.discriminator == HttpDiscriminator.NameOnly("NotFoundError")
) &&
expect(path == smithy4s.codecs.PayloadPath(List())) &&
expect(expected == "object")
expect(e.failedDecodeAttempt.isInstanceOf[DecodingFailure])
case _ => failure("Unexpected error type or values")
}
}
Expand All @@ -153,23 +143,18 @@ abstract class PizzaClientSpec extends IOSuite {
.withEntity("goodbye world"),
error => {
error match {
case RawErrorResponse(
code,
headers,
body,
FailedDecodeAttempt.UnrecognisedDiscriminator(discriminator)
) =>
expect(code == 500) &&
case e: RawErrorResponse =>
expect(e.code == 500) &&
expect(
headers == Map(
e.headers == Map(
CaseInsensitive("Content-Length") -> List("13"),
CaseInsensitive("Content-Type") -> List(
"text/plain; charset=UTF-8"
)
)
) &&
expect(body == "goodbye world") &&
expect(discriminator == HttpDiscriminator.StatusCode(500))
expect(e.body == "goodbye world") &&
expect(e.failedDecodeAttempt.discriminator == HttpDiscriminator.StatusCode(500))
case _ => failure("Unexpected error type or values")
}

Expand Down

0 comments on commit fdd4c19

Please sign in to comment.