Trying to follow some advice in this question: Is there a way to globally catch all unhandled errors in a Blazor single page application?
Of course, my rep is too low to ask follow-ups in the comments. Are all the answers still viable? I'm running into an issue with this line in the top answer:
@{ OnError(@ex); }
After making that and the corresponding code in the code-behind:
public bool OnError(Exception ex)
{
//code to send exception to dev team / log errors here
return true;
}
(And yes, I have tried it as a void rather than a bool and get the same issue), I get this error:
Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
It is pointing to line 255 in this file:Shared_MainLayout_razor.g.cs, which does not exist. The file Shared\MainLayout.razor.cs DOES exist, but there is no line 255 (stops around 150 or so).
Any ideas on how to troubleshoot? I saw this: Cannot convert lambda expression to intended delegate type because some of return types in block aren't implicitly convertible to delegate ret-type
But I don't seem to have the same situation, no nullables, and when I play with the Exception parameter it complains that it wants an Exception, so I think that part is correct.
Thanks in advance.