Skip to content

rebus-org/Unawares

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unawares

Just some AspNetCore middlewares.

Currently there's only one.

Exception Mapper

Go

app.UseExceptionMapper(
	builder => builder
		.Map<ArgumentException>(HttpStatusCode.BadRequest)
		.Map<EntityNotFoundException>(HttpStatusCode.NotFound)
		.Map<Exception>(
			status: HttpStatusCode.InternalServerError, 
			criteria: exception => exception.Message.StartsWith("oh no!")
		)
);

to map some exceptions to some HTTP status codes.

Please register it BEFORE your web app so it can catch its exceptions:

app.UseExceptionMapper(...);

// (...)

app.UseEndpoints(...);