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];
}
}
// TODO(Joey): Throw proper exceptions here
throw Exception("Availability not found");
throw AvailabilityNotFoundException();
}
@override
@ -226,9 +225,7 @@ class LocalAvailabilityDataInterface implements AvailabilityDataInterface {
return templates[index];
}
}
// TODO(Joey): Add proper exceptions in the data interface and throw them
// here
throw Exception("Template not found");
throw TemplateNotFoundException();
}
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/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
/// story to its persistance solution.
///