error
import errorFunctions
Section titled “Functions”| Function | Signature | Description |
|---|---|---|
context | (Result[T, E], String) -> Result[T, String] | Add context message to an error result. |
message | (Result[T, String]) -> String | Extract the error message from a Result, or empty string if ok. |
chain | (String, String) -> String | Chain two error messages with a cause separator. |
Reference
Section titled “Reference”error.context(r: Result[T, E], msg: String) -> Result[T, String]
Section titled “error.context(r: Result[T, E], msg: String) -> Result[T, String]”Add context message to an error result.
error.context(result, "failed to load config")error.message(r: Result[T, String]) -> String
Section titled “error.message(r: Result[T, String]) -> String”Extract the error message from a Result, or empty string if ok.
error.message(err("oops")) // => "oops"error.chain(outer: String, cause: String) -> String
Section titled “error.chain(outer: String, cause: String) -> String”Chain two error messages with a cause separator.
error.chain("load failed", "file not found") // => "load failed: file not found"