Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileProvider class error handling / reporting #143

Open
raandree opened this issue Oct 21, 2024 · 0 comments · May be fixed by #144
Open

FileProvider class error handling / reporting #143

raandree opened this issue Oct 21, 2024 · 0 comments · May be fixed by #144

Comments

@raandree
Copy link
Contributor

Datum adds instances of FileProvider as script properties to an instance of FileProvider for each folder in the Datum hierarchy.

$result = Get-ChildItem -Path $path | ForEach-Object {
    if ($_.PSIsContainer)
    {
        $val = [scriptblock]::Create("New-DatumFileProvider -Path `"$($_.FullName)`" -Store `$this.DataOptions -DatumHierarchyDefinition `$this.DatumHierarchyDefinition -Encoding `$this.Encoding")
        $this | Add-Member -MemberType ScriptProperty -Name $_.BaseName -Value $val
    }
    else
    {
        $val = [scriptblock]::Create("Get-FileProviderData -Path `"$($_.FullName)`" -DatumHandlers `$this.DatumHandlers -Encoding `$this.Encoding")
        $this | Add-Member -MemberType ScriptProperty -Name $_.BaseName -Value $val
    }
}

There are quite a few things that can go wrong when calling New-DatumFileProvider or Get-FileProviderData. However, script properties don't return errors at all, not in PowerShell 5 nor 7, as these few lines show:

$o = [object]::new()

$o | Add-Member -Name Prop1 -MemberType ScriptProperty -Value {
    'Value1'
    throw "Error"
}

$o.Prop1

I had problems loading date data and there was no indication as to why it wasn't working. Finding the error took a lot of time. To make this easier in the future, I would like to suggest using note properties. This would require changing a few lines in ‘Sampler.DscPipeline’.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant