question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnhandledExceptionHandler only handles Exceptions on Methods with Return type?

See original GitHub issue

I’m noticing that if I register an UnhandledExceptionHandler via:

ExcelIntegration.RegisterUnhandledExceptionHandler(ErrorHandler);

and an exception occurs within my ExcelFunction-marked method the handler does not trigger unless the return type is not void.

Is this intentional, or a bug?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
govertcommented, Oct 26, 2016

The exception handler gets woven into the IL method stub, which is not code I’m likely to fiddle with at this stage.

I think I didn’t make it an event since it needs to return the overridden result of the function. (I guess the event signature could have an out or ref parameter for that purpose, but maybe that didn’t occur to me at the time.)

I’m not likely to make any changes to this aspect of Excel-DNA except improved documentation.

1reaction
robodude666commented, Oct 26, 2016

Might be better to provide documentation in intellisense (and elsewhere) that highlights this expected behavior. You can still have a void function; not everyone is familiar with Visual Basic’s version of Function vs Sub.

Is there a technical limitation on why it can’t handle exceptions from void?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Function's return type can be Exception when it throws ...
The compiler allows this because throwing an exception means something wrong happened, like the arguments are invalid, or the argument is null, ...
Read more >
UnhandledExceptionFilter function (errhandlingapi.h)
An application-defined function that passes unhandled exceptions to the debugger, if the process is being debugged.
Read more >
What is an Unhandled Exception, and How to Catch All C# ...
An exception is a known type of error. An unhandled exception occurs when the application code does not properly handle exceptions.
Read more >
Application.SetUnhandledExceptionMode Method
It sets SetUnhandledExceptionMode so that all exceptions are handled by the application, regardless of the settings in the application's user configuration file ...
Read more >
Pragmatic error handling. I'll present a simple and practical…
In the unhandled exception handler, you catch and handle the non-caught exceptions (ideally, only the runtime ones). In a data repository, you could...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found