From cd8e7c31836ef5f0713d477199a73db36808a531 Mon Sep 17 00:00:00 2001 From: Alexander Huck Date: Wed, 1 Nov 2023 15:36:18 +0100 Subject: [PATCH] fix: better error handling in the transformerfactory --- internal/sync/transformer.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/sync/transformer.go b/internal/sync/transformer.go index 34eb567..f852d8e 100644 --- a/internal/sync/transformer.go +++ b/internal/sync/transformer.go @@ -1,9 +1,10 @@ package sync import ( - "fmt" "strings" + "github.com/charmbracelet/log" + "github.com/inovex/CalendarSync/internal/config" "github.com/inovex/CalendarSync/internal/models" "github.com/inovex/CalendarSync/internal/transformation" @@ -58,8 +59,8 @@ var ( func TransformerFactory(configuredTransformers []config.Transformer) (loadedTransformers []Transformer) { for _, configuredTransformer := range configuredTransformers { if _, nameExists := transformerConfigMapping[configuredTransformer.Name]; !nameExists { - // todo: handle properly - panic(fmt.Sprintf("unknown transformer: %s", configuredTransformer.Name)) + log.Warnf("unknown transformer: %s, skipping..", configuredTransformer.Name) + continue } // load the default Transformer for the configured name and initialize it based on the config transformerDefault := transformerConfigMapping[configuredTransformer.Name]