-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New attribute WebDavAnyExceptionFilterAttribute
Ensures that - in the sample server - all exceptions are returned as multi-status responses. Incorporates the changes from #38. Maybe we need to return the error element too?
- Loading branch information
1 parent
108491b
commit 5e5011e
Showing
4 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/FubarDev.WebDavServer.AspNetCore/Filters/WebDavAnyExceptionFilterAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// <copyright file="WebDavAnyExceptionFilterAttribute.cs" company="Fubar Development Junker"> | ||
// Copyright (c) Fubar Development Junker. All rights reserved. | ||
// </copyright> | ||
|
||
using System.Threading.Tasks; | ||
|
||
using FubarDev.WebDavServer.Model; | ||
|
||
using Microsoft.AspNetCore.Mvc.Filters; | ||
|
||
namespace FubarDev.WebDavServer.AspNetCore.Filters | ||
{ | ||
/// <summary> | ||
/// Attribute to handle exception filtering for WebDAV requests. | ||
/// </summary> | ||
public class WebDavAnyExceptionFilterAttribute : WebDavExceptionFilterAttribute | ||
{ | ||
/// <inheritdoc /> | ||
public override async Task OnExceptionAsync(ExceptionContext context) | ||
{ | ||
await base.OnExceptionAsync(context); | ||
|
||
if (context.ExceptionHandled) | ||
{ | ||
return; | ||
} | ||
|
||
// Return an internal server error status for all other exceptions | ||
context.Result = BuildResultForStatusCode( | ||
context, | ||
WebDavStatusCode.InternalServerError); | ||
context.ExceptionHandled = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters