GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove unneeded catch/throw from 'mkdir' and 'oss' functions by daxian-dbw · Pull Request #8425 · PowerShell/PowerShell

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Dec 7, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR Summary

Remove unneeded catch/throw from 'mkdir' and 'oss' functions.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • User-facing Documentation needed
      • Issue filed - Issue link:
  • Testing - New and feature
    • Not Applicable or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw
Remove unneeded catch/throw from 'mkdir' and 'OST' functions
acea341
@daxian-dbw Dongbo Wang (daxian-dbw) self-assigned this Dec 7, 2018
@daxian-dbw
Dongbo Wang (daxian-dbw) requested a review from Aditya Patwardhan (adityapatwardhan) December 7, 2018 23:30
@daxian-dbw
Dongbo Wang (daxian-dbw) requested a review from Bruce Payette (BrucePay) as a code owner December 7, 2018 23:30
@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Dec 8, 2018
iSazonov
Ilya (iSazonov) approved these changes Dec 8, 2018
View reviewed changes
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 2a12fb5 into PowerShell:master Dec 10, 2018
@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the mkdir branch December 10, 2018 04:53
@lzybkr

Jason Shirk (lzybkr) commented Feb 26, 2019

Copy link
Copy Markdown
Contributor

Dongbo Wang (@daxian-dbw) - sorry to have just noticed this - the seemingly unnecessary try/catch statements did serve a useful purpose at one point. I recall hating adding them, but IIRC, it improved error reporting in some useful way. Sorry, but I don't remember more than that though.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Feb 26, 2019

Copy link
Copy Markdown
Collaborator

Does it update ScriptStackTrace in errorrecord?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daxian-dbw

Dongbo Wang (daxian-dbw) commented Mar 1, 2019

Copy link
Copy Markdown
Member Author

Jason Shirk (@lzybkr) Thanks for bringing up that context. Looks like those try/catch were added only for functions that uses SteppablePipeline. Might it be related to errors thrown from within the steppable pipeline? I will play with it a bit to see if I can find out why.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daxian-dbw Dongbo Wang (daxian-dbw) mentioned this pull request Mar 2, 2019
Add 5 'InvokeAsync' overloads and 'StopAsync' to the 'PowerShell' type #8056
Merged
8 of 11 tasks
@daxian-dbw

Dongbo Wang (daxian-dbw) commented Mar 2, 2019

Copy link
Copy Markdown
Member Author

The "better error reporting" might be related to PowerShell.AddScript(...).Invoke() doesn't throw on terminating error or exception, but instead keep the errors in the error stream.
Here is one example of that:

$ps = [powershell]::create()
$ps.AddScript(@'
 try {
     Get-Process -Invalid 42
 } catch {
     throw
 }
'@)
## try/catch/throw is needed for the exception to be thrown from $ps.invoke()
$ps.Invoke()

But it doesn't seem to be the exact reason for the try/catch/throw in the original mkdir and oss.
The following throws the exception even without the try/catch/throw in mkdir:

$ps = [powershell]::create()
$ps.AddScript("mkdir -Path blahhfe:\jkfjkjakfklajlkf -ea stop") > $null
$ps.Invoke()
iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@daxian-dbw
Remove unneeded catch/throw from 'mkdir' and 'oss' functions (PowerSh…
602092b
…ell#8425)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov approved these changes
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Awaiting requested review from adityapatwardhan
@BrucePay Bruce Payette (BrucePay) Awaiting requested review from BrucePay

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@daxian-dbw Dongbo Wang (daxian-dbw)

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@daxian-dbw @lzybkr @iSazonov
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.