I'm trying to build a simple try-catch statement like the following, but that catch block never gets executed
try {
Push-OutputBinding -ErrorAction Stop -Name outputQueueItem -Value $Object
}
catch {
Write-Error "Catching Error"
# code to catch the error
}
The problem is that the azure function is not throwing the expected error as terminating besides the fact I had the ErrorAction Stop parameter. Therefore the catch code never gets executed.
Output Log:
[8/18/2020 9:42:11 PM] INFORMATION: 00:00:09.9511800
[8/18/2020 9:42:11 PM] Executed 'Functions.Monitor' (Failed, Id=6bf398bd-de2b-460f-a44b-db9838feff3f)
[8/18/2020 9:42:11 PM] System.Private.CoreLib: Exception while executing function: Functions.Monitor. Microsoft.WindowsAzure.Storage: Messages cannot be larger than 65536 bytes.
The error was expected, however, the catch code block never got executed.
Runtime Information:
Azure Functions Core Tools (3.0.2630 Commit hash: beec61496e1c5de8aa4ba38d1884f7b48233a7ab)
Function Runtime Version: 3.0.13901.0
I have also tried to change the variable $ErrorActionPreference = "Stop" but it didn't work either.