File tree 2 files changed +12
-4
lines changed
Business_Logic/Exceptions
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,14 @@ class ExceptionHandlers {
11
11
return 'Invalid data format.' ;
12
12
} else if (error is TimeoutException ) {
13
13
return 'Request timedout.' ;
14
+ } else if (error is BadRequestException ) {
15
+ return error.message.toString ();
16
+ } else if (error is UnAuthorizedException ) {
17
+ return error.message.toString ();
18
+ } else if (error is NotFoundException ) {
19
+ return error.message.toString ();
20
+ } else if (error is FetchDataException ) {
21
+ return error.message.toString ();
14
22
} else {
15
23
return 'Unknown error occured.' ;
16
24
}
Original file line number Diff line number Diff line change @@ -46,13 +46,13 @@ class BaseClient {
46
46
var responseJson = response.body;
47
47
return responseJson;
48
48
case 400 : //Bad request
49
- throw BadRequestException (response.body). message. toString ( );
49
+ throw BadRequestException (jsonDecode ( response.body)[ ' message' ] );
50
50
case 401 : //Unauthorized
51
- throw UnAuthorizedException (response.body). message. toString ( );
51
+ throw UnAuthorizedException (jsonDecode ( response.body)[ ' message' ] );
52
52
case 403 : //Forbidden
53
- throw UnAuthorizedException (response.body). message. toString ( );
53
+ throw UnAuthorizedException (jsonDecode ( response.body)[ ' message' ] );
54
54
case 404 : //Resource Not Found
55
- throw NotFoundException (response.body). message. toString ( );
55
+ throw NotFoundException (jsonDecode ( response.body)[ ' message' ] );
56
56
case 500 : //Internal Server Error
57
57
default :
58
58
throw FetchDataException (
You can’t perform that action at this time.
0 commit comments