Skip to content

Commit 312f0f0

Browse files
Merge branch 'master' into release/2.1.0
2 parents 1edc652 + 30ba45c commit 312f0f0

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

packages/dart/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Changed to the method POST on Login
66
Bug fixes
77
General improvements
88
Updated dependencies
9-
109
## 2.0.1
1110
Fixed network exceptions. [#482](https://github.com/parse-community/Parse-SDK-Flutter/pull/482)
1211

packages/dart/lib/src/objects/response/parse_exception_response.dart

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,31 @@ part of flutter_parse_sdk;
33
/// Handles exception instead of throwing an exception
44
ParseResponse 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
}

packages/flutter/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Changed to the method POST on Login
66
Bug fixes
77
General improvements
88
Updated dependencies
9-
109
## 2.0.1
1110
Fixed network exceptions. [#482](https://github.com/parse-community/Parse-SDK-Flutter/pull/482)
1211

0 commit comments

Comments
 (0)