Handle a Security API response¶
Centralizes response handling for every SecurityApi GET call: deserializes a successful response, or throws a SecurityClientException wrapping the error for any non-successful response.
| Field | Value |
|---|---|
| Operation ID | OP-15 |
| Trigger | Any SecurityClient method (OP-04 through OP-08) completes its underlying remote GET call. |
| Inputs | A urlPath and the underlying IHttpRequestResult/IHttpJsonClient response. |
| Outputs | The deserialized T result, or a thrown SecurityClientException. |
| Primary components | SecurityClient.HandleSecurityServiceGetResponse<T> |
| Entry point | src/SAIF.NetCore.AuthService/SAIF.NetCore.AuthService/SAIF.NetCore.AuthService/Clients/SecurityClient.cs |
Steps¶
await HttpClient.GetAsync(urlPath)via the injectedIHttpJsonClient.- If
result.IsSuccessful, returnresult.GetResult<T>(); otherwise thrownew SecurityClientException(result.ErrorMessage, result.ErrorException)whenErrorExceptionis not null, ornew SecurityClientException(result.ErrorMessage)otherwise (BR-AUTH-011)
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([GET request completes]) --> Success{IsSuccessful?}
Success -->|Yes| Return([Return deserialized result])
Success -->|No| HasInner{ErrorException present?}
HasInner -->|Yes| ThrowInner([Throw SecurityClientException with inner exception])
HasInner -->|No| ThrowPlain([Throw SecurityClientException with message only])
Failure and edge-case behavior¶
- There is no null/false/default fallback for a non-successful response; every caller must be prepared to catch
SecurityClientException.
Related documentation¶
Sources¶
src/SAIF.NetCore.AuthService/SAIF.NetCore.AuthService/SAIF.NetCore.AuthService/Clients/SecurityClient.cs