From b993367d6dfc1a136421cc25395a2230984391d7 Mon Sep 17 00:00:00 2001 From: Marcus Carvalho Date: Tue, 25 Feb 2020 20:44:46 +0100 Subject: [PATCH] Fixed exception handling for HTTP errors thrown by the provider --- .../Service/Controllers/ControllerTemplate.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Microsoft.SystemForCrossDomainIdentityManagement/Service/Controllers/ControllerTemplate.cs b/Microsoft.SystemForCrossDomainIdentityManagement/Service/Controllers/ControllerTemplate.cs index 53b2f0b3..bebb5124 100644 --- a/Microsoft.SystemForCrossDomainIdentityManagement/Service/Controllers/ControllerTemplate.cs +++ b/Microsoft.SystemForCrossDomainIdentityManagement/Service/Controllers/ControllerTemplate.cs @@ -609,6 +609,23 @@ public virtual async Task> Post([FromBody]T resource) throw new HttpResponseException(HttpStatusCode.NotImplemented); } + catch (HttpResponseException httpResponseException) + { + if (this.TryGetMonitor(out IMonitor monitor)) + { + IExceptionNotification notification = + ExceptionNotificationFactory.Instance.CreateNotification( + httpResponseException, + correlationIdentifier, + ServiceNotificationIdentifiers.ControllerTemplatePostNotSupportedException); + monitor.Report(notification); + } + + if (httpResponseException.Response.StatusCode == HttpStatusCode.Conflict) + return this.Conflict(); + else + return this.BadRequest(); + } catch (Exception exception) { if (this.TryGetMonitor(out IMonitor monitor))