diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 0dad515..c4bcac8 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -86,11 +86,11 @@ func LoadSourceURI(uri string) []*resource.Document { if uri != "" { ds, err := source.SourceTypes.New(uri) if err != nil { - log.Fatal(err) + slog.Error("Failed loading document from source", "error", err) } extractDocuments, extractErr := ds.ExtractResources(nil) if extractErr != nil { - log.Fatal(extractErr) + slog.Error("Failed loading resources from source", "error", extractErr) } return extractDocuments } @@ -126,7 +126,7 @@ func ImportSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) { slog.Info("main.ImportResource", "args", os.Args, "output", GlobalOutput) outputTarget, err := target.TargetTypes.New(GlobalOutput) if err != nil { - log.Fatal(err) + slog.Error("Failed opening target", "error", err) } defer outputTarget.Close() @@ -140,7 +140,7 @@ func ImportSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) { if *ImportResource != "" { slog.Info("ImportResource", "resource", ImportResource) if addResourceErr := d.AddResource(*ImportResource); addResourceErr != nil { - log.Fatal(addResourceErr) + slog.Error("Failed adding resource", "error", addResourceErr) } } diff --git a/internal/resource/declaration.go b/internal/resource/declaration.go index 5169f41..a69e164 100644 --- a/internal/resource/declaration.go +++ b/internal/resource/declaration.go @@ -114,7 +114,7 @@ func (d *Declaration) SetURI(uri string) error { slog.Info("Declaration.SetURI()", "uri", uri, "declaration", d) d.Attributes = NewResource(uri) if d.Attributes == nil { - panic("unknown resource") + return ErrUnknownResourceType } d.Type = TypeName(d.Attributes.Type()) _,e := d.Attributes.Read(context.Background()) // fix context