Web browser exception detailed page for custom thrown exceptions

Hello again,

Is it possible to use the below standard DotVVM unhandled exception page for our custom thrown exceptions? … Like for an unhandled throw new MyCustomException("some msj"); that is encountered in the code of a page’s ViewModel.

I found out that this standard unhandled exception page IS in fact showing. But it shows if throw happens in the ViewModel of the MarkupControl (which inherits from DotvvmViewModelBase). More exactly from the Init() override.
I had the throw instead in its base type (which inherits from DotvvmMarkupControl). More exactly from the OnInit() override.

What I’ve also found is that throwing from the base type also ignores a global filter which I config like this:
image
This filter is triggered as normal if throwing happens in the ViewModel.

Now, the question is: How to achieve the behavior from the “ViewModel” case also for the other case, that of the “base type”?

UPDATE

Certainly a bugger this one.
image

I found the source of it, the async void dreaded combination which still builds in 2024 :))

If I remove async, all is well: the standard unhandled exception page is shown in the browser and the global filter works.

But I need async because my code uses a 3rd party library and I must await a method from its API. Thus, if I change OnInit towards async Task of course it will fail, because no method with this return type is found to override:

So, what do you think?

The control OnInit cannot be async, the data should be fetched in the view models and controls should only use that. If this is some sort of hack you need, you can always block the thread,

(Apart from philosophical reasons why controls are not async, there are also practical reasons. The async invocations are not free, there is way more controls than view models, so the performance cost would add up. Maybe more importantly, we invoke the “missed” events on new controls when you add them to the control tree, inside the Children.Add method. If the events were async, all Children.Add calls would need to be async too…)

I see. I will resort to just make a good habbit(just a pun) of doing all my data fetching inside the view model.

Thank you kindly for responding to this and all the previous questions I had.