-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Issue Details
PR #8205 adds Break as a new enumerated value for ActionPreference. Break allows users to immediately enter the debugger when an action occurs.
The best use for this feature is to enter the debugger when an error occurs or when an exception is raised. For example, if you run a script or function that you wrote and encounter an error, you can use the new Break value of ActionPreference to re-run that same script or function and enter the debugger the moment the error occurs, whether it be a terminating error (exception) or a non-terminating error.
ActionPreference.Break can be used for any of the preference variables (e.g. $ErrorActionPreference, $WarningPreference, $DebugPreference, etc.) as well as with any of the common parameters that accept a value of type ActionPreference (e.g. -ErrorAction and -WarningAction).
This documentation update also needs to call out that like all ActionPreference values, an ActionPreference value of Break will preference will only take effect in scripts and functions if those scripts or functions are defined in the same scope as the scope in which ActionPreference.Break was used (note: the wording I placed here is awkward, because this is a hard quirk to explain -- reach out to me if you don't understand this and would like to discuss it).
Version(s) of document impacted
- Impacts 6.next document
- Impacts 6 document
- Impacts 5.1 document
- Impacts 5.0 document
- Impacts 4.0 document
- Impacts 3.0 document
Reason(s) for not selecting all version of documents
- The documented feature was introduced in selected version of PowerShell
- This issue only shows up in selected version of the document