Skip to content

Commit 540190b

Browse files
fischerscodeChralu
andauthored
Release/2.0.1 (#488)
* Dio error response (#482) * potential fix #481 * cloud function add catch Fix #484 Mightfix: #481 Co-authored-by: Chralu <[email protected]> * prepare release 2.0.1 * Fix catching timeout exception Should be inclunded into #488. Co-authored-by: Chralu <[email protected]>
1 parent fe32351 commit 540190b

File tree

9 files changed

+57
-19
lines changed

9 files changed

+57
-19
lines changed

packages/dart/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.0.1
2+
Fixed network exceptions. [#482](https://github.com/parse-community/Parse-SDK-Flutter/pull/482)
3+
14
## 2.0.0
25
##### Warning: This release contains breaking changes. If you are using flutter you should migrate using *[this](https://github.com/parse-community/Parse-SDK-Flutter/blob/release/2.0.0/docs/migrate-2-0-0.md)* guide.
36

packages/dart/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This is a work in progress and we are consistently updating it. Please let us kn
2020
To install, either add to your pubspec.yaml
2121
```yml
2222
dependencies:
23-
parse_server_sdk: ^2.0.0
23+
parse_server_sdk: ^2.0.1
2424
```
2525
or clone this repository and add to your project. As this is an early development with multiple contributors, it is probably best to download/clone and keep updating as an when a new feature is added.
2626

packages/dart/lib/src/base/parse_constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of flutter_parse_sdk;
22

33
// Library
4-
const String keySdkVersion = '2.0.0';
4+
const String keySdkVersion = '2.0.1';
55
const String keyLibraryName = 'Flutter Parse SDK';
66

77
// End Points

packages/dart/lib/src/objects/parse_function.dart

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ class ParseCloudFunction extends ParseObject {
3232
if (parameters != null) {
3333
_setObjectData(parameters);
3434
}
35-
36-
final Response<String> result = await _client.post<String>(uri,
37-
options: Options(headers: headers),
38-
data: json.encode(_getObjectData()));
39-
return handleResponse<ParseCloudFunction>(
40-
this, result, ParseApiRQ.execute, _debug, parseClassName);
35+
try {
36+
final Response<String> result = await _client.post<String>(uri,
37+
options: Options(headers: headers),
38+
data: json.encode(_getObjectData()));
39+
return handleResponse<ParseCloudFunction>(
40+
this, result, ParseApiRQ.execute, _debug, parseClassName);
41+
} on Exception catch (e) {
42+
return handleException(e, ParseApiRQ.execute, _debug, parseClassName);
43+
}
4144
}
4245

4346
/// Executes a cloud function that returns a ParseObject type
@@ -49,10 +52,15 @@ class ParseCloudFunction extends ParseObject {
4952
if (parameters != null) {
5053
_setObjectData(parameters);
5154
}
52-
final Response<String> result = await _client.post<String>(uri,
53-
options: Options(headers: headers),
54-
data: json.encode(_getObjectData()));
55-
return handleResponse<T>(this, result, ParseApiRQ.executeObjectionFunction,
56-
_debug, parseClassName);
55+
try {
56+
final Response<String> result = await _client.post<String>(uri,
57+
options: Options(headers: headers),
58+
data: json.encode(_getObjectData()));
59+
return handleResponse<T>(this, result,
60+
ParseApiRQ.executeObjectionFunction, _debug, parseClassName);
61+
} on Exception catch (e) {
62+
return handleException(
63+
e, ParseApiRQ.executeObjectionFunction, _debug, parseClassName);
64+
}
5765
}
5866
}

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/dart/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: parse_server_sdk
22
description: Dart plugin for Parse Server, (https://parseplatform.org), (https://back4app.com)
3-
version: 2.0.0
3+
version: 2.0.1
44
homepage: https://github.com/phillwiggins/flutter_parse_sdk
55

66
environment:

packages/flutter/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.0.1
2+
Fixed network exceptions. [#482](https://github.com/parse-community/Parse-SDK-Flutter/pull/482)
3+
14
## 2.0.0
25
First release.
36

packages/flutter/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This is a work in progress and we are consistently updating it. Please let us kn
1414
To install, either add to your pubspec.yaml
1515
```yml
1616
dependencies:
17-
parse_server_sdk: ^2.0.0
17+
parse_server_sdk: ^2.0.1
1818
```
1919
or clone this repository and add to your project. As this is an early development with multiple contributors, it is probably best to download/clone and keep updating as an when a new feature is added.
2020

packages/flutter/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: parse_server_sdk_flutter
22
description: Flutter plugin for Parse Server, (https://parseplatform.org), (https://back4app.com)
3-
version: 2.0.0
3+
version: 2.0.1
44
homepage: https://github.com/phillwiggins/flutter_parse_sdk
55

66
environment:
@@ -10,7 +10,7 @@ dependencies:
1010
flutter:
1111
sdk: flutter
1212

13-
parse_server_sdk: ^2.0.0
13+
parse_server_sdk: ^2.0.1
1414

1515
# Networking
1616
dio: ^3.0.10

0 commit comments

Comments
 (0)