Skip to content

Conversation

itfranck
Copy link
Collaborator


if ($null -eq $Output) {
$Message = "no such element: Unable to locate element by: $($By -join ',') with value $($Value -join ',')"
Write-Error -Exception ([System.InvalidOperationException]::new($Message))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using [System.Management.Automation.ItemNotFoundException] instead?

IMO InvalidOperation is generally used for things that would never work and can communicate that user input is somehow completely unusable, which doesn't feel like is the case here. 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vexx32 Yes, I like yours better.

I used InvalidOperation because that's what the native call produced and didn't have ItemNotFound exception in mind.

Making the change right now.

@itfranck itfranck merged commit 89333bd into V4 Sep 30, 2020
@itfranck itfranck deleted the bug/v4-GetSeElementErroManagement branch September 30, 2020 18:30
itfranck added a commit that referenced this pull request Oct 13, 2020
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 this pull request may close these issues.

2 participants