mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
Add device icons based on device type and update network exception handling
- Add logic to set device icons based on device type in DeviceModel.fromJson method - Update network exception handling to parse HTML response in ServerFailure class - Add html package as a dependency for parsing HTML responses -Added Devices Icons by updateing device types mapping
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:html/parser.dart' as parser;
|
||||
|
||||
abstract class Failure {
|
||||
final String errMessage;
|
||||
@ -28,8 +29,12 @@ class ServerFailure extends Failure {
|
||||
return ServerFailure("Bad certificate!");
|
||||
|
||||
case DioExceptionType.badResponse:
|
||||
return ServerFailure.fromResponse(dioError.response!.statusCode!,
|
||||
dioError.response!.data!["message"]);
|
||||
{
|
||||
var document = parser.parse(dioError.response!.data.toString());
|
||||
var message = document.body!.text;
|
||||
return ServerFailure.fromResponse(
|
||||
dioError.response!.statusCode!, message);
|
||||
}
|
||||
case DioExceptionType.cancel:
|
||||
return ServerFailure("The request to ApiServer was canceled");
|
||||
|
||||
|
Reference in New Issue
Block a user