File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed
Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ Changed to the method POST on Login
66Bug fixes
77General improvements
88Updated dependencies
9-
109## 2.0.1
1110Fixed network exceptions. [ #482 ] ( https://github.com/parse-community/Parse-SDK-Flutter/pull/482 )
1211
Original file line number Diff line number Diff line change @@ -3,7 +3,31 @@ part of flutter_parse_sdk;
33/// Handles exception instead of throwing an exception
44ParseResponse buildParseResponseWithException (Exception exception) {
55 final ParseResponse response = ParseResponse ();
6- response.error =
7- ParseError (message: exception.toString (), exception: exception);
6+ if (exception is DioError ) {
7+ try {
8+ Map <String , dynamic > errorResponse;
9+
10+ try {
11+ errorResponse =
12+ json.decode (exception.response? .data? .toString () ?? '{}' );
13+ } catch (_) {}
14+
15+ errorResponse ?? = < String , dynamic > {};
16+
17+ response.error = ParseError (
18+ message: errorResponse['error' ]? .toString () ??
19+ exception.response? .statusMessage,
20+ exception: exception,
21+ code: errorResponse['code' ] ?? exception.response? .statusCode,
22+ );
23+ } catch (error) {
24+ response.error = ParseError (
25+ message: "Failed to build ParseResponse with exception" ,
26+ exception: error);
27+ }
28+ } else {
29+ response.error =
30+ ParseError (message: exception.toString (), exception: exception);
31+ }
832 return response;
933}
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ Changed to the method POST on Login
66Bug fixes
77General improvements
88Updated dependencies
9-
109## 2.0.1
1110Fixed network exceptions. [ #482 ] ( https://github.com/parse-community/Parse-SDK-Flutter/pull/482 )
1211
You can’t perform that action at this time.
0 commit comments