Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 31b2570

Browse files
committed
add error handling docs
1 parent c85afc9 commit 31b2570

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

docs/error-handling.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
id: error-handling
3+
title: Error Handling
4+
---
5+
6+
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:
7+
8+
1. [**GraphQL Errors**](#graphql-errors): Errors returned by your GraphQL server.
9+
2. [**Stream Errors**](#stream-errors): Errors emitted by any Stream in your TypedLink chain.
10+
3. [**Forwarding Exceptions**](#forwarding-exceptions): Synchronous Exceptions thrown when forwarding a request along the TypedLink chain.
11+
12+
## GraphQL Errors
13+
14+
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).
15+
16+
Ferry's `GqlTypedLink` (included in the default `Client`) parses GraphQL Errors from responses and includes them in the `OperationResponse.graphqlErrors` field.
17+
18+
## Stream Errors
19+
20+
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 `OperationResponse`s, including the error in the `linkException` field.
21+
22+
## Forwarding Exceptions
23+
24+
Ferry allows `TypedLink`s 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 `OperationResponse`.
25+
26+
As with virtually everything in `Ferry`, the error handling logic can be customized with a [custom](customization.md) `TypedLink`.

docs/flutter-operation-widget.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class AllPokemonScreen extends StatelessWidget {
3434
builder: (
3535
BuildContext context,
3636
OperationResponse<GAllPokemonData, GAllPokemonVars> response,
37+
Object error,
3738
) {
3839
if (response.loading)
3940
return Center(child: CircularProgressIndicator());

sidebars.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
mainSidebar: {
33
Ferry: ['intro', 'how-it-works'],
44
'Getting Started': ['setup', 'codegen'],
5-
Fetching: ['queries', 'mutations', 'fetch-policies', 'pagination'],
5+
Fetching: ['queries', 'mutations', 'fetch-policies', 'pagination', 'error-handling'],
66
Caching: ['cache-configuration', 'cache-interaction', 'garbage-collection'],
77
Flutter: ['flutter', 'flutter-operation-widget'],
88
Advanced: ['custom-scalars', 'customization'],

0 commit comments

Comments
 (0)