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

Throw specific exception when initialization is rejected #611

Merged
merged 1 commit into from
Jul 16, 2024
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
4 changes: 4 additions & 0 deletions core/src/main/scala/clue/GraphQLException.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
package clue

import clue.model.GraphQLErrors
import io.circe.JsonObject

class GraphQLException(msg: String) extends Exception(msg)

case class ConnectionException() extends GraphQLException("Could not establish connection")

case class RemoteInitializationException(payload: JsonObject)
extends GraphQLException(s"The server returned an error on initialization: [$payload]")

case class DisconnectedException() extends GraphQLException("Connection was closed")

case class InvalidSubscriptionIdException(id: String)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/clue/websocket/ApolloClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class ApolloClient[F[_], P, S](
case Initializing(stateConnectionId, connection, _, _, latch)
if connectionId === stateConnectionId =>
Connected(connectionId, connection) ->
latch.complete(s"Initialization rejected by server: [$payload].".error).void
latch.complete(RemoteInitializationException(payload).asLeft).void
case s => s -> s"Unexpected connection_error received from server.".warnF
}
case Right(StreamingMessage.FromServer.Data(subscriptionId, response)) =>
Expand Down
Loading