mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-11 07:51:45 +00:00
add exception for empty conditions
This commit is contained in:
@ -330,6 +330,15 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
CreateSceneWithTasksEvent event, Emitter<CreateSceneState> emit) async {
|
||||
emit(CreateSceneLoading());
|
||||
try {
|
||||
// Check for empty conditions or actions
|
||||
if (event.createAutomationModel != null) {
|
||||
if (event.createAutomationModel!.conditions.isEmpty) {
|
||||
throw Exception('Conditions are required');
|
||||
}
|
||||
if (event.createAutomationModel!.actions.isEmpty) {
|
||||
throw Exception('Actions are required');
|
||||
}
|
||||
}
|
||||
dynamic response;
|
||||
if (event.createSceneModel != null) {
|
||||
response = event.updateScene
|
||||
@ -358,8 +367,11 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
} else {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
emit(CreateSceneError(message: e.toString()));
|
||||
} catch (e) {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
} finally {
|
||||
emit(AddSceneTask(
|
||||
tasksList: tasksList,
|
||||
automationTasksList: automationTasksList,
|
||||
|
||||
Reference in New Issue
Block a user