Skip to content

Commit 9beb9ec

Browse files
authored
Merge pull request #199 from Cray-HPE/NGSM-1569
NGSM-1569 add additional error handling when there is no active session
2 parents ddac6ce + d40cd51 commit 9beb9ec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/domain/misc.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* MIT License
44
*
5-
* (C) Copyright 2023 Hewlett Packard Enterprise Development LP
5+
* (C) Copyright 2023, 2025 Hewlett Packard Enterprise Development LP
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a
88
* copy of this software and associated documentation files (the "Software"),
@@ -38,6 +38,13 @@ import (
3838

3939
// List returns the inventory
4040
func (d *Domain) List() (inventory.Inventory, error) {
41+
if d == nil {
42+
return inventory.Inventory{}, fmt.Errorf("domain not initialized - no active session found. Run 'session init' to begin")
43+
}
44+
if d.datastore == nil {
45+
return inventory.Inventory{}, fmt.Errorf("datastore not initialized - no active session found. Run 'session init' to begin")
46+
}
47+
4148
inv, err := d.datastore.List()
4249
if err != nil {
4350
return inventory.Inventory{}, err

0 commit comments

Comments
 (0)