mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
@ -17,34 +17,34 @@ class ServerFailure extends Failure {
|
||||
factory ServerFailure.fromDioError(DioException dioError) {
|
||||
switch (dioError.type) {
|
||||
case DioExceptionType.connectionTimeout:
|
||||
return ServerFailure('Connection timeout with the Server.');
|
||||
return ServerFailure("Connection timeout with the Server.");
|
||||
case DioExceptionType.sendTimeout:
|
||||
return ServerFailure('Send timeout with the Server.');
|
||||
return ServerFailure("Send timeout with the Server.");
|
||||
|
||||
case DioExceptionType.receiveTimeout:
|
||||
return ServerFailure('Receive timeout with the Server.');
|
||||
return ServerFailure("Receive timeout with the Server.");
|
||||
|
||||
case DioExceptionType.badCertificate:
|
||||
return ServerFailure('Bad certificate!');
|
||||
return ServerFailure("Bad certificate!");
|
||||
|
||||
case DioExceptionType.badResponse:
|
||||
{
|
||||
// var document = parser.parse(dioError.response!.data.toString());
|
||||
// var message = document.body!.text;
|
||||
return ServerFailure.fromResponse(dioError.response!.statusCode,
|
||||
dioError.response?.data['message'] ?? 'Error');
|
||||
return ServerFailure.fromResponse(dioError.response!.statusCode!,
|
||||
dioError.response?.data['message'] ?? "Error");
|
||||
}
|
||||
case DioExceptionType.cancel:
|
||||
return ServerFailure('The request to ApiServer was canceled');
|
||||
return ServerFailure("The request to ApiServer was canceled");
|
||||
|
||||
case DioExceptionType.connectionError:
|
||||
return ServerFailure('No Internet Connection');
|
||||
return ServerFailure("No Internet Connection");
|
||||
|
||||
case DioExceptionType.unknown:
|
||||
return ServerFailure('Unexpected Error, Please try again!');
|
||||
return ServerFailure("Unexpected Error, Please try again!");
|
||||
|
||||
default:
|
||||
return ServerFailure('Unexpected Error, Please try again!');
|
||||
return ServerFailure("Unexpected Error, Please try again!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,9 +54,9 @@ class ServerFailure extends Failure {
|
||||
case 403:
|
||||
return ServerFailure(responseMessage);
|
||||
case 400:
|
||||
final errors = <String>[];
|
||||
List<String> errors = [];
|
||||
if (responseMessage is List) {
|
||||
for (final error in responseMessage) {
|
||||
for (var error in responseMessage) {
|
||||
errors.add(error);
|
||||
}
|
||||
} else {
|
||||
@ -64,11 +64,11 @@ class ServerFailure extends Failure {
|
||||
}
|
||||
return ServerFailure(errors.join('\n'));
|
||||
case 404:
|
||||
return ServerFailure('');
|
||||
return ServerFailure("");
|
||||
case 500:
|
||||
return ServerFailure(responseMessage);
|
||||
default:
|
||||
return ServerFailure('Opps there was an Error, Please try again!');
|
||||
return ServerFailure("Opps there was an Error, Please try again!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user