From 32f96987519422f282a0eb4de1674606609efd21 Mon Sep 17 00:00:00 2001
From: martina <martina@freirad.at>
Date: Thu, 26 Sep 2024 13:57:28 +0200
Subject: [PATCH] refactor: add error handling for unknown channel type, #146

---
 CHANGELOG.md                     | 1 +
 src/aura_engine/core/channels.py | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d8bf560c..9cbef29d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Added
 
+- added error handling if no matching channel type is found
 - ...
 
 ### Changed
diff --git a/src/aura_engine/core/channels.py b/src/aura_engine/core/channels.py
index b32e5216..3bb362a7 100644
--- a/src/aura_engine/core/channels.py
+++ b/src/aura_engine/core/channels.py
@@ -601,6 +601,8 @@ class ChannelFactory:
         Returns:
             (GenericChannel): A concrete implementation of the generic channel
 
+        Raises:
+            ValueError: If no matching channel type is found
         """
         if channel_name in ChannelType.QUEUE.channels:
             self.logger.debug(f"Create new QUEUE channel '{channel_name}'")
@@ -611,8 +613,11 @@ class ChannelFactory:
         if channel_name in ChannelType.LIVE.channels:
             self.logger.debug(f"Create new LINE channel '{channel_name}'")
             return LineChannel(channel_index, channel_name, mixer)
-        # FIXME: Error handling when no ChannelType was found
-        self.logger.error("No ChannelType found! Now stuff is not working as intended")
+        error_message = (
+            f"No valid ChannelType found for channel '{channel_name}'. Not working as intended."
+        )
+        self.logger.error(error_message)
+        raise ValueError(error_message)
 
 
 class PlayoutStatusResponse(StrEnum):
-- 
GitLab