public async Task ClearSubscriptionsAsync(GatewayRequest request) { try { // Validates parameter if ((request.ObserverEntityId?.ServiceUri == null) || (request.ObserverEntityId.ActorId == null)) { throw new ArgumentException($"Parameter {nameof(request)} is null or invalid.", nameof(request)); } // Gets actor proxy IClientObserverActor proxy = GetActorProxy( new ActorId(request.ObserverEntityId.ActorId), request.ObserverEntityId.ServiceUri); if (proxy == null) { throw new ApplicationException("The ActorProxy cannot be null."); } // Invokes actor using proxy ServiceEventSource.Current.Message($"Clearing observer subscriptions...\r\n[Observer]: {request.ObserverEntityId}"); await proxy.ClearSubscriptionsAsync(); } catch (AggregateException ex) { if (!(ex.InnerExceptions?.Count > 0)) { throw new HttpResponseException(this.Request.CreateErrorResponse(HttpStatusCode.NotFound, ex.Message)); } foreach (Exception exception in ex.InnerExceptions) { ServiceEventSource.Current.Message(exception.Message); } throw new HttpResponseException(this.Request.CreateErrorResponse(HttpStatusCode.NotFound, ex.Message)); } catch (Exception ex) { ServiceEventSource.Current.Message(ex.Message); throw new HttpResponseException(this.Request.CreateErrorResponse(HttpStatusCode.NotFound, ex.Message)); } }