Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a way to distinguish different github errors #230

Merged
merged 3 commits into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ trait HttpRequestBuilderExtensionJS {
mapResponse(r)
case r ⇒
Either.left(
UnexpectedException(
s"Failed invoking with status : ${r.statusCode}, body : \n ${r.body}"))
UnsuccessfulHttpRequest(
s"Failed invoking with status : ${r.statusCode}, body : \n ${r.body}",
r.statusCode
))
}

def emptyResponse(r: SimpleHttpResponse): GHResponse[Unit] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

package github4s

import github4s.GithubResponses.{GHResponse, GHResult, JsonParsingException, UnexpectedException}
import github4s.GithubResponses._
import io.circe.Decoder
import io.circe.parser._

import scalaj.http._
import cats.implicits._
import github4s.free.interpreters.Capture
Expand Down Expand Up @@ -79,7 +78,11 @@ trait HttpRequestBuilderExtensionJVM {
mapResponse(r)
case r ⇒
Either.left(
UnexpectedException(s"Failed invoking with status : ${r.code} body : \n ${r.body}"))
UnsuccessfulHttpRequest(
s"Failed invoking with status : ${r.code} body : \n ${r.body}",
r.code
)
)
}

def emptyResponse(r: HttpResponse[String]): GHResponse[Unit] =
Expand Down
5 changes: 5 additions & 0 deletions github4s/shared/src/main/scala/github4s/GithubResponses.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ object GithubResponses {
json: String
) extends GHException(msg)

case class UnsuccessfulHttpRequest(
msg: String,
statusCode: Int
) extends GHException(msg)

case class UnexpectedException(msg: String) extends GHException(msg)

}