When creating or running an application, sooner or later, you're bound to encounter some type of error. Ferry is designed to gracefully handle errors, including:
- GraphQL Errors: Errors returned by your GraphQL server.
- Stream Errors: Errors emitted by any Stream in your TypedLink chain.
- Forwarding Exceptions: Synchronous Exceptions thrown when forwarding a request along the TypedLink chain.
GraphQL Errors are errors received by your
gql_link. These are commonly returned by a GraphQL server when there is a problem validating or executing your GraphQL operation (e.g. your Query includes a field not defined in your schema).
GqlTypedLink (included in the default
Client) parses GraphQL Errors from responses and includes them in the
Dart Streams allow errors to be emmited as events in the stream. Ferry's
ErrorTypedLink (included in the default
Client) intercepts these Stream error events and converts them into
OperationResponses, including the error in the
TypedLinks to be composed into an execution chain by calling
forward() from within a
TypedLink.request() method. If an exception is thrown when forwarding a request along the chain, Ferry's
ErrorTypedLink will catch the exception and convert it into an
As with virtually everything in
Ferry, the error handling logic can be customized with a custom