You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting-started/README.md
+1-28Lines changed: 1 addition & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,32 +57,5 @@ throw an exception.
57
57
All `ExecuteAsync` overloads, however, behave in the same way as `Execute` and return
58
58
the `IRestResponse` or `IRestResponse<T>`.
59
59
60
-
See below about how RestSharp handles exceptions.
60
+
Read [here](../usage/exceptions.md) about how RestSharp handles exceptions.
61
61
62
-
## Note About Error Handling
63
-
64
-
If there is a network transport error (network is down, failed DNS lookup, etc), `RestResponse.ResponseStatus` will be set to `ResponseStatus.Error`, otherwise it will be `ResponseStatus.Completed`.
65
-
66
-
If an API returns a 404, `ResponseStatus` will still be `Completed`. If you need access to the HTTP status code returned you will find it at `RestResponse.StatusCode`.
67
-
The `Status` property is an indicator of completion independent of the API error handling.
68
-
69
-
Normally, RestSharp doesn't throw an exception if the request fails.
70
-
71
-
However, it is possible to configure RestSharp to throw in different situations, when it normally doesn't throw
72
-
in favour of giving you the error as a property.
73
-
74
-
| Property | Behavior |
75
-
| ------------- |-------------|
76
-
|`FailOnDeserialization`| Changes the default behavior when failed deserialization results in a successful response with an empty `Data` property of the response. Setting this property to `true` will tell RestSharp to consider failed deserialization as an error and set the `ResponseStatus` to `Error` accordingly. |
77
-
|`ThrowOnDeserialization`| Changes the default behavior when failed deserialization results in empty `Data` property of the response. Setting this property to `true` will tell RestSharp to throw when deserialization fails. |
78
-
|`ThrowOnAnyError`| Setting this property to `true` changes the default behavior and forces RestSharp to throw if any errors occurs when making a request or during deserialization. |
79
-
80
-
Those properties are available for the `IRestClient` instance and will be used for all request made with that instance.
81
-
82
-
There are also slight differences on how different overloads handle exceptions.
83
-
84
-
Asynchronous generic methods `GetAsync<T>`, `PostAsync<T>` and so on, which aren't a part of `IRestClient` interface
85
-
(those methods are extension methods) return `Task<T>`. It means that there's no `IRestResponse` to set the response status to error.
86
-
We decided to throw an exception when such a request fails. It is a trade-off between the API
87
-
consistency and usability of the library. Usually, you only need the content of `RestResponse` instance to diagnose issues
88
-
and most of the time the exception would tell you what's wrong.
If there is a network transport error (network is down, failed DNS lookup, etc), `RestResponse.ResponseStatus` will be set to `ResponseStatus.Error`, otherwise it will be `ResponseStatus.Completed`.
4
+
5
+
If an API returns a 404, `ResponseStatus` will still be `Completed`. If you need access to the HTTP status code returned you will find it at `RestResponse.StatusCode`.
6
+
The `Status` property is an indicator of completion independent of the API error handling.
7
+
8
+
Normally, RestSharp doesn't throw an exception if the request fails.
9
+
10
+
However, it is possible to configure RestSharp to throw in different situations, when it normally doesn't throw
11
+
in favour of giving you the error as a property.
12
+
13
+
| Property | Behavior |
14
+
| ------------- |-------------|
15
+
|`FailOnDeserialization`| Changes the default behavior when failed deserialization results in a successful response with an empty `Data` property of the response. Setting this property to `true` will tell RestSharp to consider failed deserialization as an error and set the `ResponseStatus` to `Error` accordingly. |
16
+
|`ThrowOnDeserialization`| Changes the default behavior when failed deserialization results in empty `Data` property of the response. Setting this property to `true` will tell RestSharp to throw when deserialization fails. |
17
+
|`ThrowOnAnyError`| Setting this property to `true` changes the default behavior and forces RestSharp to throw if any errors occurs when making a request or during deserialization. |
18
+
19
+
Those properties are available for the `IRestClient` instance and will be used for all request made with that instance.
20
+
21
+
There are also slight differences on how different overloads handle exceptions.
22
+
23
+
Asynchronous generic methods `GetAsync<T>`, `PostAsync<T>` and so on, which aren't a part of `IRestClient` interface
24
+
(those methods are extension methods) return `Task<T>`. It means that there's no `IRestResponse` to set the response status to error.
25
+
We decided to throw an exception when such a request fails. It is a trade-off between the API
26
+
consistency and usability of the library. Usually, you only need the content of `RestResponse` instance to diagnose issues
27
+
and most of the time the exception would tell you what's wrong.
0 commit comments