Skip to content

Commit 026f90f

Browse files
Copilotjohlju
andcommitted
Remove duplicate .NET section and unnecessary return after -ErrorAction Stop
Co-authored-by: johlju <[email protected]>
1 parent b3ad133 commit 026f90f

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,6 @@ catch
430430
-TargetObject $DatabaseName `
431431
-Exception $_.Exception `
432432
-ErrorAction 'Stop'
433-
434-
return
435433
}
436434
```
437435

@@ -456,32 +454,6 @@ catch
456454
}
457455
```
458456

459-
##### .NET Method Exceptions
460-
461-
.NET methods (like SMO objects) throw exceptions automatically - no special error
462-
handling needed. Just use try-catch:
463-
464-
```powershell
465-
try
466-
{
467-
$alertObject.Drop() # Throws exception on failure
468-
Write-Verbose -Message ($script:localizedData.AlertRemoved -f $alertObject.Name)
469-
}
470-
catch
471-
{
472-
$errorMessage = $script:localizedData.RemoveFailed -f $alertObject.Name
473-
474-
Write-Error -Message $errorMessage `
475-
-Category 'InvalidOperation' `
476-
-ErrorId 'RMA0001' `
477-
-TargetObject $alertObject `
478-
-Exception $_.Exception `
479-
-ErrorAction 'Stop'
480-
481-
return
482-
}
483-
```
484-
485457
##### Parameter Validation with ValidateScript
486458

487459
When using `[ValidateScript()]` attribute, use `throw` for validation failures
@@ -500,7 +472,6 @@ When using `[ValidateScript()]` attribute, use `throw` for validation failures
500472
[System.String]
501473
$Path
502474
```
503-
```
504475

505476
##### Pipeline Processing Considerations
506477

0 commit comments

Comments
 (0)