Try Catch with Nested Display Form Not Catching
I am wondering if this is by design but I am noticing that if you have a Try Catch, with a Display Form in the Try and that form produces an error the Catch does not trigger.
I was looking for a simple throw everything into a Try block when I noticed this occurring. Is the only way to handle this to place a Try block in the form events?
I have included an example of the failing one with a Try around everything and a successful one with the Try in the event.
-
Hi @Kevin Rathgeber? ,
Thanks for mentioning this. It looks like a bug to me. I tried replacing the Display Form with a Container to give this structure:
- try
- container
- web request
- container
- catch
- alert
In this case, the error from the web request caused the alert to be shown.
I think that we had intended Display Form to do the same, as the code looks like it's attempting to switch to the catch path.
I've logged a bug to follow up on this. For future communication on this, please refer to bug #47798.
0 - try
-
Hi @Kevin Rathgeber? ,
I've been looking into this issue today. I realized that this behaviour is by design. When an error occurs in a form event, the current error handling allows the rest of the form to load and continue to operate.
In order to achieve the behaviour you expected, the form would need to be closed. This would be too much of a breaking change to introduce into the product.
I'm interested to learn more about your use case. Would you prefer for the form to close? If enough people wanted such a feature, we could consider introducing a new input to the Display Form activity that causes it to fail when there's an error. I'd need to understand more about the benefits, though, before considering such a change.
0 -
From my point of view if an unhandled error is produced in the form, I would expect it to bubble up to the next available handler if there is one. So if an error occurs in a form and that portion of the form is not already in a Try/Catch I think closing it would be acceptable in order for the outer Try/Catch to catch it.
0 -
That makes sense to me, too. I think if we were starting from scratch that's likely the behaviour I'd want.
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
4 kommentarer