# Class ErrorReportingExceptionLoggerMiddleware (4.4.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [4.4.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.ErrorReportingExceptionLoggerMiddleware)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.ErrorReportingExceptionLoggerMiddleware)

    public sealed class ErrorReportingExceptionLoggerMiddleware

Middleware that will, when invoked, call the next [RequestDelegate](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.requestdelegate),
catch any exception that it may throw, send that exception to the
Google Cloud Error Reporting API and rethrow the given exception.

## Inheritance

[Object](https://learn.microsoft.com/dotnet/api/system.object) \> ErrorReportingExceptionLoggerMiddleware

## Inherited Members

[Object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode#system-object-gethashcode) [Object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype#system-object-gettype) [Object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone#system-object-memberwiseclone) [Object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring#system-object-tostring)

## Namespace

[Google.Cloud.Diagnostics.AspNetCore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore)

## Assembly

Google.Cloud.Diagnostics.AspNetCore.dll

## Constructors

### ErrorReportingExceptionLoggerMiddleware(RequestDelegate, IExceptionLogger)

    public ErrorReportingExceptionLoggerMiddleware(RequestDelegate next, IExceptionLogger logger)

Create a new instance of [ErrorReportingExceptionLoggerMiddleware](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.ErrorReportingExceptionLoggerMiddleware).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `next` | `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.requestdelegate` The next request delegate. Must not be null. |
| `logger` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.IExceptionLogger` A logger that will report exceptions. Must not be null. |

## Methods

### Invoke(HttpContext)

    public Task Invoke(HttpContext httpContext)

Invokes the next [RequestDelegate](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.requestdelegate), catches any exception thrown,
reports the exception to the Google Cloud Error Reporting API and rethrows
the exception.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `httpContext` | `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.httpcontext` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` |   |