We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a0d7f9a commit 75c518cCopy full SHA for 75c518c
platform-includes/capture-error/powershell.mdx
@@ -10,3 +10,17 @@ catch
10
$_ | Out-Sentry
11
}
12
```
13
+
14
+Or you can install a `trap` in a block to log errors that occur within that block.
15
+Be sure to understand how `trap` works especially in regards to scope and how the execution continues/breaks when `trap` is used.
16
17
+```powershell
18
+AFunctionThatMightFail
19
20
+# The trap will get called even if it is declared after the code that throws.
21
+# It's because traps are processed by PowerShell before the script is executed.
22
+trap
23
+{
24
+ $_ | Out-Sentry
25
+}
26
+```
0 commit comments