Created
February 4, 2025 17:24
-
-
Save steviecoaster/eebb5f61dbfc7615331e2c8455108608 to your computer and use it in GitHub Desktop.
Create a PowerShell Custom Exception class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SteviecoasterException : System.Exception { # create a new exception called SteviecoasterException that inherits all of its magic from System.Exception | |
SteviecoaserException([string]$message) : base($message) {} # message is the text you wish to display as your exception | |
} | |
# Use your new class | |
throw [SteviecoasterException]::new('Welp, I ded') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment