diff --git a/pkg/genesis/io.go b/pkg/genesis/io.go index 8c9d88e955..c013bd28ce 100644 --- a/pkg/genesis/io.go +++ b/pkg/genesis/io.go @@ -55,7 +55,7 @@ func LoadGenesis(genesisPath string) (Genesis, error) { // Validate and clean the file path cleanPath := filepath.Clean(genesisPath) if _, err := os.Stat(cleanPath); os.IsNotExist(err) { - return Genesis{}, fmt.Errorf("genesis file not found at path: %s", cleanPath) + return Genesis{}, fmt.Errorf("genesis file not found at path %s: %w", cleanPath, err) } genesisJSON, err := os.ReadFile(cleanPath) diff --git a/pkg/genesis/io_test.go b/pkg/genesis/io_test.go index 7c8b882a6f..4b50ee26e2 100644 --- a/pkg/genesis/io_test.go +++ b/pkg/genesis/io_test.go @@ -109,6 +109,9 @@ func TestLoadGenesis_FileNotFound(t *testing.T) { _, err := LoadGenesis("nonexistent.json") assert.Error(t, err) assert.Contains(t, err.Error(), "genesis file not found") + assert.ErrorIs(t, err, os.ErrNotExist) + var pathErr *os.PathError + assert.ErrorAs(t, err, &pathErr) } func TestLoadGenesis_InvalidJSON(t *testing.T) {