fix some error handling
This commit is contained in:
parent
5f7db0b4d0
commit
39f29fd029
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user