1/** @Log.Failure.Builders — error values attached to events */2modulePuduLangLog.Failure34importPuduLangLog.Domain.DisplayasDisplay5importPuduLangLogasLog67/// A failure of a kind with a message.8exportfnof(kind: Str, message: Str) -> Log.Failure { Log.Failure{kind: kind, message: message, trace: [], causes: []} }910/// A failure from any error value: its kind is the given name and its message the value's text.11exportfnfrom[E](kind: Str, error: E) -> Log.Failure {12let text = show(error)13let unquoted = if text.length() >= 2 && text.startsWith("\"") && text.endsWith("\"") { text.slice(1, text.length() - 1) } else { text }14 of(kind, unquoted)15}1617/// The failure with trace lines added, innermost call first.18exportfnwithTrace(problem: &Log.Failure, lines: Array[Str]) -> Log.Failure { Log.Failure{..*problem, trace: problem.trace.concat(lines)} }1920/// The failure with another failure recorded as its cause.21exportfncausedBy(problem: &Log.Failure, cause: Log.Failure) -> Log.Failure { Log.Failure{..*problem, causes: problem.causes.push(cause)} }2223/// The failure as text: `Kind: message`, its trace, and its causes.24exportfndescribe(problem: &Log.Failure) -> Str { Display.failure(problem) }25