Failure.md
PuduLangLog.Failure
type: module path: "@root/src/PuduLangLog/Failure.pudu" fidelity: Active grammar: "[[grammar/pudu]]" depth_score: 0.3 depth_status: SHALLOW tags: [module, leaf] aliases: [PuduLangLog.Failure]
Purpose
Builds the [[domain/Failure|failure]] attached to an event: a kind, a message, trace lines, and causes.
Interface
Signatures
export fn of(kind: Str, message: Str) -> Log.Failure
export fn from[E](kind: Str, error: E) -> Log.Failure
export fn withTrace(problem: &Log.Failure, lines: Array[Str]) -> Log.Failure
export fn causedBy(problem: &Log.Failure, cause: Log.Failure) -> Log.Failure
export fn describe(problem: &Log.Failure) -> StrLinkage
- Requires: [[src/PuduLangLog]], [[src/PuduLangLog/Domain/Display]].
- Consumed by: package users, [[src/PuduLangLog/Timing]], and the request logger.
Algorithm
fromnames the kind and takes the message fromshowof any error value, without the quotesshowputs around text.withTraceappends trace lines;causedByappends a cause;describerenders all of it.
Negative Logic (Prohibited Paths)
- Nothing here raises or unwinds; a failure is only data.
Edge Cases
- An empty message renders as the kind alone.
Depth
DEPTH 0.3 (SHALLOW). Tested by test/PuduLangLog/ValueTest.
Grill Log
- Q: Why name the kind explicitly in
from? A: Pudu cannot name a value's type at run time; the caller knows it. _Rejected:_ a generic kind such asError.
Referenced by
[[domain/Failure]] · [[src/PuduLangLog/_MOC]] · [[src/PuduLangLog/Timing]]
