Skip to content

Commit

Permalink
specific exception for init rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
rpiaggio committed Jul 16, 2024
1 parent 52b9565 commit 30346cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit 30346cc

Please sign in to comment.