fix: throw dedicated exceptions rather than generic ones

This commit is contained in:
Bart Ribbers 2024-07-18 14:07:34 +02:00 committed by Freek van de Ven
parent 1e33d2b7cb
commit d765a7a0f8
2 changed files with 8 additions and 5 deletions

View file

@ -207,8 +207,7 @@ class LocalAvailabilityDataInterface implements AvailabilityDataInterface {
return availabilities[index]; return availabilities[index];
} }
} }
// TODO(Joey): Throw proper exceptions here throw AvailabilityNotFoundException();
throw Exception("Availability not found");
} }
@override @override
@ -226,9 +225,7 @@ class LocalAvailabilityDataInterface implements AvailabilityDataInterface {
return templates[index]; return templates[index];
} }
} }
// TODO(Joey): Add proper exceptions in the data interface and throw them throw TemplateNotFoundException();
// here
throw Exception("Template not found");
} }
int _id = 1; int _id = 1;

View file

@ -1,6 +1,12 @@
import "package:flutter_availability_data_interface/src/models/availability.dart"; import "package:flutter_availability_data_interface/src/models/availability.dart";
import "package:flutter_availability_data_interface/src/models/templates.dart"; import "package:flutter_availability_data_interface/src/models/templates.dart";
/// Exception thrown when the requested availability can not be found
class AvailabilityNotFoundException implements Exception {}
/// Exception thrown when the requested template can not be found
class TemplateNotFoundException implements Exception {}
/// A base interface that defines the communication from the availability user /// A base interface that defines the communication from the availability user
/// story to its persistance solution. /// story to its persistance solution.
/// ///