简体   繁体   中英

How to debug exeptions thrown in rebus handlers?

What is the recommended way do debug exceptions during development in localhost being throws in handlers like this:

class MyEventHandler : IHandleMessages<MyEvent>
{
    public async Task Handle(BlogLinkCreated message)
    {
        await Task.Delay(100);
        throw new Exception();
    } 
}

I see some exceptions in the debug output, but I don't know from where they came. I want to see stacktrace and ideally step trough callstack and see local variables' values.

Rebus logs exceptions caught when executing handlers, including everything that the exceptions reveal about themselves by calling .ToString() on them.

This includes the full stack trace, and if you're running a Debug build of your code, it will also include source file line numbers.

It should be pretty easy – provided that you haven't disabled logging somehow – to figure out which line of code throws any exception that bubbles out for Rebus to see.

If you're using Visual Studio to develop your code, you can also just hit F5 (or whichever hotkey you're using to launch your app with the debugger attached) and then wait until the debugger breaks on the exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM