11import 'dart:async' ;
2+
23import 'dart:convert' ;
3- import 'dart:io' ;
4+ import 'package:http/http.dart' as http ;
45
56import '../../Business_Logic/Exceptions/exception_handlers.dart' ;
6- import 'package:http/http.dart' as http;
77
88class BaseClient {
99 static const int timeOutDuration = 35 ;
@@ -15,14 +15,8 @@ class BaseClient {
1515 var response =
1616 await http.get (uri).timeout (const Duration (seconds: timeOutDuration));
1717 return _processResponse (response);
18- } on SocketException {
19- throw const SocketException ('Socket exception' );
20- } on TimeoutException {
21- throw ApiNotRespondingException ('Server not responding.' );
22- } on FormatException {
23- } on HttpException {
2418 } catch (e) {
25- throw e. toString ( );
19+ throw ExceptionHandlers (). getExceptionString (e );
2620 }
2721 }
2822
@@ -36,11 +30,9 @@ class BaseClient {
3630 .timeout (const Duration (seconds: timeOutDuration));
3731
3832 return _processResponse (response);
39- } on SocketException {
40- } on TimeoutException {
41- throw ApiNotRespondingException ('Server not responding.' );
42- } on FormatException {
43- } on HttpException {}
33+ } catch (e) {
34+ throw ExceptionHandlers ().getExceptionString (e);
35+ }
4436 }
4537
4638 //DELETE
@@ -54,13 +46,13 @@ class BaseClient {
5446 var responseJson = response.body;
5547 return responseJson;
5648 case 400 : //Bad request
57- throw BadRequestException (response.body);
49+ throw BadRequestException (response.body).message. toString () ;
5850 case 401 : //Unauthorized
59- throw UnAuthorizedException (response.body);
51+ throw UnAuthorizedException (response.body).message. toString () ;
6052 case 403 : //Forbidden
61- throw UnAuthorizedException (response.body);
53+ throw UnAuthorizedException (response.body).message. toString () ;
6254 case 404 : //Resource Not Found
63- throw NotFoundException (response.body);
55+ throw NotFoundException (response.body).message. toString () ;
6456 case 500 : //Internal Server Error
6557 default :
6658 throw FetchDataException (
0 commit comments