From b17fa17ff75842afa5e1fe7c8c1af6eeeebb6397 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 23 Jan 2024 20:20:20 +0100 Subject: bench time --- src/c_parse.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/c_parse.go') diff --git a/src/c_parse.go b/src/c_parse.go index 61d4dfc..c26b4f5 100644 --- a/src/c_parse.go +++ b/src/c_parse.go @@ -57,22 +57,21 @@ import ( "gopkg.in/yaml.v3" ) -func c_read_yaml_file(file string) *HostNode { +func c_read_yaml_file(file string, ui *HardUI) (*HostNode, error) { var host HostNode yaml_file, err := os.ReadFile(file) if err != nil { - // TODO: remove all c_dies with c_err_mode - c_die("error reading file " + file, err) + return nil, err } - if err = yaml.Unmarshal(yaml_file, &host); err != nil { - c_die("error reading yaml file " + file, err) + if err := yaml.Unmarshal(yaml_file, &host); err != nil { + return nil, err } if len(host.Name) == 0 { - return nil + return nil, nil } if len(host.Host) == 0 { - return nil + return nil, nil } if host.Protocol == 0 { if host.Port == 0 { @@ -103,10 +102,10 @@ func c_read_yaml_file(file string) *HostNode { host.Height = 1200 } } else if host.Protocol > 1 { - return nil + return nil, nil } if host.Quality > 2 { host.Quality = 2 } - return &host + return &host, nil } -- cgit v1.2.3