Skip to content

Commit

Permalink
replace all log.Fatalf's with plain log and let upper layer die
Browse files Browse the repository at this point in the history
log.Fatalf kills the process it is running, as a library, we want to give this
control flow to the consumer of our library
  • Loading branch information
Memet Bilgin committed Sep 23, 2024
1 parent 0856861 commit 09ed957
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions libvirt/data_source_libvirt_node_device_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})

err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device generic into deviceXML: %#v", deviceXML)

Expand All @@ -501,7 +501,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})
deviceXML := DeviceSystem{}
err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal device system XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal device system XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device system into deviceXML: %v", deviceXML)

Expand Down Expand Up @@ -531,7 +531,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})
deviceXML := DevicePCI{}
err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal device pci XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal device pci XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device pci into deviceXML: %v", deviceXML)

Expand Down Expand Up @@ -578,7 +578,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})
deviceXML := DeviceUSBDevice{}
err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal device usb_device XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal device usb_device XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device usb_device into deviceXML: %v", deviceXML)

Expand All @@ -603,7 +603,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})
deviceXML := DeviceUSB{}
err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal device usb XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal device usb XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device usb into deviceXML: %v", deviceXML)

Expand All @@ -623,7 +623,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})
deviceXML := DeviceStorage{}
err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal device storage XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal device storage XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device storage into deviceXML: %v", deviceXML)

Expand All @@ -646,7 +646,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})
deviceXML := DeviceNet{}
err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal device net XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal device net XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device net into deviceXML: %v", deviceXML)

Expand All @@ -672,7 +672,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})
deviceXML := DeviceSCSI{}
err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal device scsi XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal device scsi XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device scsi into deviceXML: %v", deviceXML)

Expand All @@ -693,7 +693,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})
deviceXML := DeviceSCSIHost{}
err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal device scsi_host XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal device scsi_host XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device scsi_host into deviceXML: %v", deviceXML)

Expand All @@ -711,7 +711,7 @@ func resourceLibvirtNodeDeviceInfoRead(d *schema.ResourceData, meta interface{})
deviceXML := DeviceDRM{}
err = xml.Unmarshal([]byte(xmlDesc), &deviceXML)
if err != nil {
log.Fatalf("failed to unmarshal device drm XML into deviceXML: %v", err)
log.Printf("[ERROR] failed to unmarshal device drm XML into deviceXML: %v", err)
}
log.Printf("[DEBUG] Parsed device drm into deviceXML: %v", deviceXML)

Expand Down

0 comments on commit 09ed957

Please sign in to comment.