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

Commit 12663a9

Browse files
committed
Aggiunto esempio StatusCode 503 - Service Unavailable
1 parent 1e7b497 commit 12663a9

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/CustomLibrary.ProblemDetails.Sample/Controllers/TestController.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System.Net.Mime;
2-
using Microsoft.AspNetCore.Mvc;
3-
4-
namespace CustomLibrary.ProblemDetails.Sample.Controllers;
1+
namespace CustomLibrary.ProblemDetails.Sample.Controllers;
52

63
[ApiController]
74
[Route("api/[controller]")]
@@ -193,4 +190,18 @@ public async Task<IActionResult> GetExceptionBadGatewayAsync()
193190
return ResponseException.BadGateway(HttpContext, exc);
194191
}
195192
}
193+
194+
[HttpGet("ServiceUnavailable")]
195+
public async Task<IActionResult> GetExceptionServiceUnavailableAsync()
196+
{
197+
try
198+
{
199+
await Task.Delay(500);
200+
throw new Exception.ServiceUnavailableException("Service Unavailable");
201+
}
202+
catch (Exception.ServiceUnavailableException exc)
203+
{
204+
return ResponseException.ServiceUnavailable(HttpContext, exc);
205+
}
206+
}
196207
}

0 commit comments

Comments
 (0)