fix(do-not-disturb): return empty schedule on 404 instead of error
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import '../../../features/do_not_disturb/domain/do_not_disturb_period.dart';
|
||||
@@ -19,6 +20,14 @@ class DoNotDisturbRemoteDatasourceImpl implements DoNotDisturbRemoteDatasource {
|
||||
);
|
||||
final model = DoNotDisturbResponseDto.fromJson(response.data!);
|
||||
return _toEntity(model.item);
|
||||
} on DioException catch (e) {
|
||||
if (e.response?.statusCode == 404) {
|
||||
return DoNotDisturbSchedule(
|
||||
id: '',
|
||||
deviceIdentificator: identificator,
|
||||
);
|
||||
}
|
||||
throw Exception('Error fetching do not disturb schedule');
|
||||
} catch (_) {
|
||||
throw Exception('Error fetching do not disturb schedule');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user