darkoperator / darkoperator/Posh-SSH
Get-SFTPChildItem does not throw an error
Open
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
The CmdLet Get-ChildItem does not throw a terminating error when the path is not found and ErrorAction = 'Stop'
try {
Get-SFTPChildItem @sessionParams -Path '/notExstingPath' -Recurse -ErrorAction Stop
# displays error but does not end up in the catch clause:
# Error listing items in /notExstingPath: Exception calling "ListDirectory" with "1" argument(s): "No such file"
}
catch {
"Oops: $_"
}
workaround
try {
$errorMessage = $null
Get-SFTPChildItem @sessionParams -Path '/notexsting' -Recurse -EA Stop -ErrorVariable 'errorMessage'
if($errorMessage) {
throw $errorMessage
}
}
catch {
"Oops: $_"
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Get-SFTPChildItem cmdlet and reproduce the provided example using -Path '/notExstingPath', -Recurse, and -ErrorAction Stop. Trace how the missing-path error is emitted, then verify that the same command reaches the catch clause rather than only displaying an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100