From e771ad0ed8207ad69671052fedbc7a9aeee5a1ab Mon Sep 17 00:00:00 2001 From: Petrus Nguyen Thai Hoc Date: Mon, 12 Dec 2022 14:12:21 +0700 Subject: [PATCH] fix(remote) --- android/app/build.gradle | 6 +++--- lib/data/remote/api_service.dart | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 8720421..7755897 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion flutter.compileSdkVersion + compileSdkVersion 33 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -44,8 +44,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.hoc.node_auth" - minSdkVersion flutter.minSdkVersion - targetSdkVersion flutter.targetSdkVersion + minSdkVersion 21 + targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true diff --git a/lib/data/remote/api_service.dart b/lib/data/remote/api_service.dart index 14d464e..34068eb 100644 --- a/lib/data/remote/api_service.dart +++ b/lib/data/remote/api_service.dart @@ -28,8 +28,16 @@ class ApiService implements RemoteDataSource { rethrow; } on SocketException catch (e, s) { throw RemoteDataSourceException('No internet connection', e, s); - } on SimpleHttpClientException catch (e, s) { - throw RemoteDataSourceException('Http error', e, s); + } on SimpleTimeoutException catch (e, s) { + throw RemoteDataSourceException('Timeout error', e, s); + } on SimpleErrorResponseException catch (e, s) { + String message; + try { + message = jsonDecode(e.errorResponseBody)['message'] as String; + } catch (_) { + message = 'Http error'; + } + throw RemoteDataSourceException(message, e, s); } catch (e, s) { throw RemoteDataSourceException('Other error', e, s); }