Skip to content

Commit 1658549

Browse files
authored
Merge pull request #128 from lohanidamodar/fix-flutter-sdk-file-issues
fix-flutter-sdk-file-issues
2 parents 92f3c06 + 5e5529d commit 1658549

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

templates/dart/lib/client.dart.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ class Client {
9696
if(e.response == null) {
9797
throw {{spec.title | caseUcfirst}}Exception(e.message);
9898
}
99+
if(responseType == ResponseType.bytes) {
100+
if(e.response.headers['content-type'].contains('application/json')) {
101+
final res = json.decode(utf8.decode(e.response.data));
102+
throw {{spec.title | caseUcfirst}}Exception(res['message'],res['code'], e.response);
103+
} else {
104+
throw {{spec.title | caseUcfirst}}Exception(e.message);
105+
}
106+
}
99107
throw {{spec.title | caseUcfirst}}Exception(e.response.data['message'],e.response.data['code'], e.response.data);
100108
} catch(e) {
101109
throw {{spec.title | caseUcfirst}}Exception(e.message);

templates/dart/lib/package.dart.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
library {{ language.params.packageName }};
22

33
import 'dart:io';
4+
import 'dart:convert';
45
import 'package:dio/dio.dart';
56
import 'package:meta/meta.dart';
67
import 'package:dio/adapter.dart';

templates/flutter/lib/client.dart.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ class Client {
127127
if(e.response == null) {
128128
throw {{spec.title | caseUcfirst}}Exception(e.message);
129129
}
130+
if(responseType == ResponseType.bytes) {
131+
if(e.response.headers['content-type'].contains('application/json')) {
132+
final res = json.decode(utf8.decode(e.response.data));
133+
throw {{spec.title | caseUcfirst}}Exception(res['message'],res['code'], e.response);
134+
} else {
135+
throw {{spec.title | caseUcfirst}}Exception(e.message);
136+
}
137+
}
130138
throw {{spec.title | caseUcfirst}}Exception(e.response.data['message'],e.response.data['code'], e.response.data);
131139
} catch(e) {
132140
throw {{spec.title | caseUcfirst}}Exception(e.message);

templates/flutter/lib/package.dart.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
library {{ language.params.packageName }};
22

33
import 'dart:io';
4+
import 'dart:convert';
45
import 'package:universal_html/html.dart' as html;
56
import 'package:dio/dio.dart';
67
import 'package:meta/meta.dart';

0 commit comments

Comments
 (0)