Construct SAIF exceptions¶
Create the library's exception types used by implementation libraries for application-level errors. This operation is triggered when implementation-library code throws new SAIFException(message[, inner]) or new HttpStatusCodeException(message[, inner]).
| Field | Value |
|---|---|
| Operation ID | OP-05 |
| Trigger | Implementation-library code throws new SAIFException(message[, inner]) or new HttpStatusCodeException(message[, inner]). |
| Inputs | message (string), optional inner (Exception) |
| Outputs | A SAIFException or HttpStatusCodeException instance ready to be thrown. |
| Primary components | SAIFException..ctor, HttpStatusCodeException..ctor |
| Entry point | src/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/SAIFException.cs |
Steps¶
- Pass
message/innerto theSystem.Exceptionbase constructor. - For
HttpStatusCodeException,ContentTypeinitializes to"text/plain"andStatusCodestays at theintdefault0until the consumer sets it. (BR-009) SAIFException.LogDetailsremainsnullby default until the thrower assigns it.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Throw site constructs exception]) --> Base["Call System.Exception base constructor<br>with message and inner"]
Base --> IsHttp{HttpStatusCodeException?}
IsHttp -->|Yes| DefaultContentType["ContentType defaults to text/plain, StatusCode defaults to 0"]
IsHttp -->|No| LogDetails[LogDetails remains null until assigned]
DefaultContentType --> End([Exception ready to throw])
LogDetails --> End
Failure and edge-case behavior¶
- No validation occurs;
messagemay benullor empty and both exception types construct successfully.
Related documentation¶
Sources¶
src/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/SAIFException.cssrc/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/HttpStatusCodeException.cs