public sealed class ErrorReportingExceptionLoggerMiddleware
Middleware that will, when invoked, call the next RequestDelegate,
catch any exception that it may throw, send that exception to the
Google Cloud Error Reporting API and rethrow the given exception.
A logger that will report exceptions. Must not be null.
Methods
Invoke(HttpContext)
public Task Invoke(HttpContext httpContext)
Invokes the next RequestDelegate, catches any exception thrown,
reports the exception to the Google Cloud Error Reporting API and rethrows
the exception.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eErrorReportingExceptionLoggerMiddleware\u003c/code\u003e class is a middleware designed to catch exceptions, report them to the Google Cloud Error Reporting API, and then rethrow the exception.\u003c/p\u003e\n"],["\u003cp\u003eThis middleware utilizes a \u003ccode\u003eRequestDelegate\u003c/code\u003e to process the next request in the pipeline and an \u003ccode\u003eIExceptionLogger\u003c/code\u003e to handle the reporting of exceptions.\u003c/p\u003e\n"],["\u003cp\u003eThe middleware's \u003ccode\u003eInvoke\u003c/code\u003e method executes the next \u003ccode\u003eRequestDelegate\u003c/code\u003e, handles any exceptions that arise, and communicates them to the Error Reporting API.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of this middleware is 4.4.0, and version 4.3.1 is also available for use, both providing the same functionality.\u003c/p\u003e\n"]]],[],null,["# Class ErrorReportingExceptionLoggerMiddleware (4.4.0)\n\nVersion latestkeyboard_arrow_down\n\n- [4.4.0 (latest)](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.ErrorReportingExceptionLoggerMiddleware)\n- [4.3.1](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.ErrorReportingExceptionLoggerMiddleware) \n\n public sealed class ErrorReportingExceptionLoggerMiddleware\n\nMiddleware that will, when invoked, call the next [RequestDelegate](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.requestdelegate),\ncatch any exception that it may throw, send that exception to the\nGoogle Cloud Error Reporting API and rethrow the given exception. \n\nInheritance\n-----------\n\n[Object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e ErrorReportingExceptionLoggerMiddleware \n\nInherited Members\n-----------------\n\n[Object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode#system-object-gethashcode) \n[Object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype#system-object-gettype) \n[Object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone#system-object-memberwiseclone) \n[Object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring#system-object-tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Diagnostics.AspNetCore](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore)\n\nAssembly\n--------\n\nGoogle.Cloud.Diagnostics.AspNetCore.dll\n\nConstructors\n------------\n\n### ErrorReportingExceptionLoggerMiddleware(RequestDelegate, IExceptionLogger)\n\n public ErrorReportingExceptionLoggerMiddleware(RequestDelegate next, IExceptionLogger logger)\n\nCreate a new instance of [ErrorReportingExceptionLoggerMiddleware](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.ErrorReportingExceptionLoggerMiddleware).\n\nMethods\n-------\n\n### Invoke(HttpContext)\n\n public Task Invoke(HttpContext httpContext)\n\nInvokes the next [RequestDelegate](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.requestdelegate), catches any exception thrown,\nreports the exception to the Google Cloud Error Reporting API and rethrows\nthe exception."]]