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 != "" {
|
if uri != "" {
|
||||||
ds, err := source.SourceTypes.New(uri)
|
ds, err := source.SourceTypes.New(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
slog.Error("Failed loading document from source", "error", err)
|
||||||
}
|
}
|
||||||
extractDocuments, extractErr := ds.ExtractResources(nil)
|
extractDocuments, extractErr := ds.ExtractResources(nil)
|
||||||
if extractErr != nil {
|
if extractErr != nil {
|
||||||
log.Fatal(extractErr)
|
slog.Error("Failed loading resources from source", "error", extractErr)
|
||||||
}
|
}
|
||||||
return extractDocuments
|
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)
|
slog.Info("main.ImportResource", "args", os.Args, "output", GlobalOutput)
|
||||||
outputTarget, err := target.TargetTypes.New(GlobalOutput)
|
outputTarget, err := target.TargetTypes.New(GlobalOutput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
slog.Error("Failed opening target", "error", err)
|
||||||
}
|
}
|
||||||
defer outputTarget.Close()
|
defer outputTarget.Close()
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ func ImportSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
|||||||
if *ImportResource != "" {
|
if *ImportResource != "" {
|
||||||
slog.Info("ImportResource", "resource", ImportResource)
|
slog.Info("ImportResource", "resource", ImportResource)
|
||||||
if addResourceErr := d.AddResource(*ImportResource); addResourceErr != nil {
|
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)
|
slog.Info("Declaration.SetURI()", "uri", uri, "declaration", d)
|
||||||
d.Attributes = NewResource(uri)
|
d.Attributes = NewResource(uri)
|
||||||
if d.Attributes == nil {
|
if d.Attributes == nil {
|
||||||
panic("unknown resource")
|
return ErrUnknownResourceType
|
||||||
}
|
}
|
||||||
d.Type = TypeName(d.Attributes.Type())
|
d.Type = TypeName(d.Attributes.Type())
|
||||||
_,e := d.Attributes.Read(context.Background()) // fix context
|
_,e := d.Attributes.Read(context.Background()) // fix context
|
||||||
|
Loading…
Reference in New Issue
Block a user