fix(do-not-disturb): return empty schedule on 404 instead of error

This commit is contained in:
2026-04-21 17:58:52 +02:00
parent 6694a4b0ce
commit c60761adab

View File

@@ -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');
}