Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 2e8a76f

Browse files
might as well
1 parent a5cff14 commit 2e8a76f

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/SqlStreamStore.HAL/ExceptionHandlingMiddleware.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using Halcyon.HAL;
6+
using Microsoft.AspNetCore.Builder;
67
using Newtonsoft.Json;
78
using SqlStreamStore.Streams;
89
using MidFunc = System.Func<
@@ -45,7 +46,10 @@ private static readonly IDictionary<Type, Func<Exception, Response>> s_exception
4546
[typeof(Exception)] = s_defaultExceptionHandler
4647
};
4748

48-
public static MidFunc HandleExceptions => async (context, next) =>
49+
public static IApplicationBuilder UseExceptionHandling(this IApplicationBuilder builder)
50+
=> builder.Use(HandleExceptions);
51+
52+
private static MidFunc HandleExceptions => async (context, next) =>
4953
{
5054
try
5155
{

src/SqlStreamStore.HAL/SqlStreamStoreHalMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static IApplicationBuilder UseSqlStreamStoreHal(
7676
throw new ArgumentNullException(nameof(streamStore));
7777

7878
return builder
79-
.Use(ExceptionHandlingMiddleware.HandleExceptions)
79+
.UseExceptionHandling()
8080
.Use(CaseSensitiveQueryStrings)
8181
.Use(AcceptHalJson)
8282
.Use(HeadRequests)

0 commit comments

Comments
 (0)