Title: Use correct exceptions · Issue #19212 · PowerShell/PowerShell · GitHub
Open Graph Title: Use correct exceptions · Issue #19212 · PowerShell/PowerShell
X Title: Use correct exceptions · Issue #19212 · PowerShell/PowerShell
Description: Summary of the new feature / enhancement In PowerShell code base there are some places where we are not accurate with exceptions. Typical example: PowerShell/src/System.Management.Automation/engine/CommandInfo.cs Lines 286 to 294 in 4314...
Open Graph Description: Summary of the new feature / enhancement In PowerShell code base there are some places where we are not accurate with exceptions. Typical example: PowerShell/src/System.Management.Automation/engine...
X Description: Summary of the new feature / enhancement In PowerShell code base there are some places where we are not accurate with exceptions. Typical example: PowerShell/src/System.Management.Automation/engine...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/19212
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use correct exceptions","articleBody":"### Summary of the new feature / enhancement\n\nIn PowerShell code base there are some places where we are not accurate with exceptions.\r\nTypical example: https://github.com/PowerShell/PowerShell/blob/4314e634cadde65a743d359106def376ed1c59ee/src/System.Management.Automation/engine/CommandInfo.cs#L286-L294\r\n\r\nHere we throw ArgumentNullException that is not correct if the argument is empty. (There are examples with other exceptions.)\r\n\r\nMy proposal is to fix such code and throw ArgumentNullException if argument is null and ArgumentException is argument is empty.\r\n\r\nThis is not even a breaking change, as it is not a functional exception, and it is worth correcting it for the correct one. If someone even uses this behavior in their code, it is catastrophically bad code.\r\n\r\nThe proposal comes from the fact that we are blocked from using new .Net API like ArgumentException.ThrowIfNullOrEmpty(). The API makes code more friendly for .Net Rumtime optimizations (like inlining). We already use this kind of API in a lot of places and it's worth updating the rest.\n\n### Proposed technical implementation details (optional)\n\n_No response_","author":{"url":"https://github.com/iSazonov","@type":"Person","name":"iSazonov"},"datePublished":"2023-02-24T15:26:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/19212/PowerShell/issues/19212"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6b553777-bdc4-5a48-ff2b-eb4eed6adefe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E82C:276C3B:1370949:1C3D3F4:6A54D6F3 |
| html-safe-nonce | 626cc31eef86837def804654054c36b770806558d86af717e2adb83545fed166 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODJDOjI3NkMzQjoxMzcwOTQ5OjFDM0QzRjQ6NkE1NEQ2RjMiLCJ2aXNpdG9yX2lkIjoiNzUyMDI0ODc0NzkxOTcyNjMyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 782607b98c3b421d84715cade95c87b411947dd3d4a7f9415a8481c8bff1f5f6 |
| hovercard-subject-tag | issue:1598847638 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/19212/issue_layout |
| twitter:image | https://opengraph.githubassets.com/17c7f534532f389bc736d828bd646f1aca8eaaba376f2778aa881d6fe3663129/PowerShell/PowerShell/issues/19212 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/17c7f534532f389bc736d828bd646f1aca8eaaba376f2778aa881d6fe3663129/PowerShell/PowerShell/issues/19212 |
| og:image:alt | Summary of the new feature / enhancement In PowerShell code base there are some places where we are not accurate with exceptions. Typical example: PowerShell/src/System.Management.Automation/engine... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iSazonov |
| hostname | github.com |
| expected-hostname | github.com |
| None | a556215b071af6609619e2bbe6f00bdfbf0812ad723b1ae6c301858a7a829f54 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 840b5d20d5a883c23cf56f5240b2c343d6cc0867 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width