Title: Rule request: The Catch (or Finally) statement is missing its Try block. · Issue #2098 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: Rule request: The Catch (or Finally) statement is missing its Try block. · Issue #2098 · PowerShell/PSScriptAnalyzer
X Title: Rule request: The Catch (or Finally) statement is missing its Try block. · Issue #2098 · PowerShell/PSScriptAnalyzer
Description: There is a rule for The Try statement is missing its Catch or Finally block.: Invoke-ScriptAnalyzer -ScriptDefinition {function Test { Try { write-verbose 'Test' } }}.ToString() ParserError: Line | 1 | … criptDefinition {function Test { ...
Open Graph Description: There is a rule for The Try statement is missing its Catch or Finally block.: Invoke-ScriptAnalyzer -ScriptDefinition {function Test { Try { write-verbose 'Test' } }}.ToString() ParserError: Line |...
X Description: There is a rule for The Try statement is missing its Catch or Finally block.: Invoke-ScriptAnalyzer -ScriptDefinition {function Test { Try { write-verbose 'Test' } }}.ToString() ParserError...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/2098
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Rule request: The Catch (or Finally) statement is missing its Try block.","articleBody":"There is a rule for **The Try statement is missing its Catch or Finally block.**:\n\n```PowerShell\nInvoke-ScriptAnalyzer -ScriptDefinition {function Test { Try { write-verbose 'Test' } }}.ToString()\nParserError:\nLine |\n 1 | … criptDefinition {function Test { Try { write-verbose 'Test' } }}.ToSt …\n | ~\n | The Try statement is missing its Catch or Finally block.\n```\n\nBut there is no rule for the opposite: a `Catch` (or `Finally`) statement that is missing its `Try` block:\n\n```PowerShell\nInvoke-ScriptAnalyzer -ScriptDefinition {function Test { Catch { write-verbose 'Test' } }}.ToString()\n```\n\nEven it produces a syntax error during run time (as it assumes it is a cmdlet, which is definitely not a recommend function name):\n```PowerShell\nCatch { write-verbose'Test' }\nCatch: The term 'Catch' is not recognized as a name of a cmdlet, function, script file, or executable program.\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.\n```\n","author":{"url":"https://github.com/iRon7","@type":"Person","name":"iRon7"},"datePublished":"2025-04-29T12:55:11Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/2098"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:0cf74b84-1619-10c7-38b8-6620e4c92238 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D8B2:1D98FB:2E62D2:3D4E7D:6AFCE477 |
| html-safe-nonce | 66c90b01e208375e00ecd1d36d0181bfe099952b034d66de4d8decd866c6274c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOEIyOjFEOThGQjoyRTYyRDI6M0Q0RTdEOjZBRkNFNDc3IiwidmlzaXRvcl9pZCI6IjQzOTI5ODA3OTIyNDY4NTQ3NzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ef8a4596380e8db5bb8c47ef276e7be12dc83e653ad178f8c6606d5b57b1ab73 |
| hovercard-subject-tag | issue:3028236270 |
| 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/PSScriptAnalyzer/2098/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b7a52ee5ead84044b7b83e69c9a6d332a9a1b94e4dc1d61b531ef2e3216628e0/PowerShell/PSScriptAnalyzer/issues/2098 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b7a52ee5ead84044b7b83e69c9a6d332a9a1b94e4dc1d61b531ef2e3216628e0/PowerShell/PSScriptAnalyzer/issues/2098 |
| og:image:alt | There is a rule for The Try statement is missing its Catch or Finally block.: Invoke-ScriptAnalyzer -ScriptDefinition {function Test { Try { write-verbose 'Test' } }}.ToString() ParserError: Line |... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iRon7 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 99aede4c5f55ec5cf06666a8c9e03ebf9f85f7231223e7f1c38c16e5504835b3 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 33149177 |
| octolytics-dimension-repository_nwo | PowerShell/PSScriptAnalyzer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33149177 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PSScriptAnalyzer |
| 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 | ecfd63ca125ec74b42f74eeb158b3fa081c8c497 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width