Skip to content

Commit 6f5a872

Browse files
committed
fixing when no response and other small fixes
1 parent 6401953 commit 6f5a872

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

templates/flutter/lib/client.dart.twig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,25 @@ class Client {
110110

111111
try {
112112
if(headers['content-type'] == 'multipart/form-data') {
113-
return http.request(path, data: FormData.fromMap(params), options: options);
113+
return await http.request(path, data: FormData.fromMap(params), options: options);
114114
}
115115

116116
if (method == HttpMethod.get) {
117117
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
118118
params[key] = params[key].toString();
119119
}});
120120

121-
return http.get(path, queryParameters: params, options: options);
121+
return await http.get(path, queryParameters: params, options: options);
122122
} else {
123-
return http.request(path, data: params, options: options);
123+
return await http.request(path, data: params, options: options);
124124
}
125125
} on DioError catch(e) {
126+
if(e.response == null) {
127+
throw {{spec.title | caseUcfirst}}AppwriteException(e.message);
128+
}
126129
throw {{spec.title | caseUcfirst}}Exception(e.response.data['message'],e.response.data['code'], e.response.data);
127130
} catch(e) {
128-
throw {{spec.title | caseUcfirst}}Exception(e.message, 0);
131+
throw {{spec.title | caseUcfirst}}Exception(e.message);
129132
}
130133
}
131134
}

templates/flutter/lib/exception.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ class {{spec.title | caseUcfirst}}Exception implements Exception {
55
final int code;
66
final dynamic response;
77

8-
{{spec.title | caseUcfirst}}Exception([this.message = "", this.code = 0, this.response]);
8+
{{spec.title | caseUcfirst}}Exception([this.message = "", this.code, this.response]);
99

1010
}

0 commit comments

Comments
 (0)