MCPcopy Create free account
hub / github.com/hashintel/hash / parse_config

Function parse_config

libs/error-stack/examples/parse_config.rs:32–41  ·  view source on GitHub ↗
(path: impl AsRef<Path>)

Source from the content-addressed store, hash-verified

30struct Suggestion(&'static str);
31
32fn parse_config(path: impl AsRef<Path>) -> Result<Config, Report<ParseConfigError>> {
33 let path = path.as_ref();
34
35 let content = fs::read_to_string(path)
36 .change_context(ParseConfigError::new())
37 .attach_opaque(Suggestion("use a file you can read next time!"))
38 .attach_with(|| format!("could not read file {}", path.display()))?;
39
40 Ok(content)
41}
42
43fn main() {
44 if let Err(report) = parse_config("config.json") {

Callers 1

mainFunction · 0.70

Calls 6

SuggestionClass · 0.85
OkInterface · 0.85
as_refMethod · 0.45
attach_withMethod · 0.45
attach_opaqueMethod · 0.45
change_contextMethod · 0.45

Tested by

no test coverage detected