NickCraver / StackExchange.Exceptional

Error handler used for the Stack Exchange network
https://nickcraver.com/StackExchange.Exceptional/
Apache License 2.0
860 stars 170 forks source link

Add netstandard & ASP.NET Core support #80

Closed NickCraver closed 6 years ago

NickCraver commented 7 years ago

V2 needs ASP.NET Core and netstandard support included. This will follow the library split patterns of MiniProfiler, but there's a blocker in play. A critical component of Exceptional is AppDomain.UnhandledException, but unfortunately this isn't coming back until netstandard2.0.

That issue is resolved here: https://github.com/dotnet/corefx/issues/6398, just waiting for that release to get going. Now that I've figured out patterns and beat the crap out of the build system with MiniProfiler, actually porting StackExchange.Exceptional won't be a huge task.

mmillican commented 7 years ago

@NickCraver Do you have any thoughts on the mail sending for Exceptional as it relates to the port? Using jstedfast/MailKit perhaps?

nickalbrecht commented 7 years ago

The AppDomain's exception handler will be nice to have once it's out. Any plans to have an interim build that will support ASP.NET Core (regardless if the underlying framework is full .NET or .NET Core) and just register it as a Middleware handler, similar to the UseDeveloperExceptionPage() implementation? Or as a Logging implementation for calls Log() that include exception details?

NickCraver commented 6 years ago

master has a first pass of ASP.NET Core support, lots of tweaking and such to do, but samples are up. I'm looking at the built-in error page and thinking yeah, we should have an option to have it render on the throw (instead of just re-throwing), that's next up.

NickCraver commented 6 years ago

Here's an example of the current functionality in master:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseExceptional(settings => 
    {
        settings.ApplicationName = "Samples.AspNetCore";
        settings.UseExceptionalPageOnThrow = env.IsDevelopment();
    });
}

And here's the result: screen shot 2017-08-09 at 22 05 15 screen shot 2017-08-09 at 22 04 57

You can: register it as a middleware (always logging and optionally handling the throw page like above) and you can just new Exception("blah").Log(Context) anywhere (or without context with LogWithoutContext()).

Closing this out to cleanup, we'll have settings in soon to round out support - alpha around the corner.