Format an exception for the error log¶
Format an exception into a sentinel-delimited error-log entry, triggered when caller writes a caught exception to an error-log store.
| Field | Value |
|---|---|
| Operation ID | OP-022 |
| Trigger | Caller writes a caught exception to an error-log store |
| Inputs | instance |
| Outputs | string — short message, sentinel, then full detail |
| Primary components | ExceptionExtensions.GetErrorLogFormattedException(this Exception) |
| Entry point | Common/SAIF.Common/Extensions/ExceptionExtensions.cs |
Steps¶
- If the exception is null, return
string.Empty. (BR-049) - Collect the exception chain and reverse it so the innermost exception is first. (BR-050)
- Seed a
StringBuilderwith the innermost exception'sMessage— the short summary a log reader sees first. (BR-052) - Append the delimiter constant
ErrorLogMessageString="@#ELOG#@"to separate summary from detail. (BR-052) - Append the full formatted output of OP-021 and return. (BR-050, BR-051)
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start(["Caller writes exception<br>to error log"]) --> C1{"Exception is null?"}
C1 -->|Yes| Empty([Return string.Empty])
C1 -->|No| S2["Collect exception chain,<br>reverse so innermost is first"]
S2 --> S3["Seed StringBuilder with<br>innermost exception's Message"]
S3 --> S4["Append sentinel '@#ELOG#@'"]
S4 --> S5["Append full formatted<br>output of OP-021"]
S5 --> End([Return assembled string])
Related documentation¶
Sources¶
Common/SAIF.Common/Extensions/ExceptionExtensions.cs