diff options
| author | Loyalsoldier <[email protected]> | 2024-08-31 12:34:38 +0800 |
|---|---|---|
| committer | Loyalsoldier <[email protected]> | 2024-08-31 12:34:38 +0800 |
| commit | 1e4cb746b9ca67b9d9dabdc65f42f495eb4cfbcd (patch) | |
| tree | ee3de1a60416c7f56dcc99a2cf7715b9b8f4e5a2 /plugin/maxmind | |
| parent | deff06ac0f59751bb9857bc7d645b756b6133ddf (diff) | |
Chore: make error messages consistent across formats
Diffstat (limited to 'plugin/maxmind')
| -rw-r--r-- | plugin/maxmind/asn_csv.go | 4 | ||||
| -rw-r--r-- | plugin/maxmind/country_csv.go | 10 | ||||
| -rw-r--r-- | plugin/maxmind/mmdb_in.go | 2 | ||||
| -rw-r--r-- | plugin/maxmind/mmdb_out.go | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/plugin/maxmind/asn_csv.go b/plugin/maxmind/asn_csv.go index e738a44b..8c90d60d 100644 --- a/plugin/maxmind/asn_csv.go +++ b/plugin/maxmind/asn_csv.go @@ -129,7 +129,7 @@ func (g *geoLite2ASNCSV) Input(container lib.Container) (lib.Container, error) { } if len(entries) == 0 { - return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", typeASNCSV, g.Action) + return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", g.Type, g.Action) } var ignoreIPType lib.IgnoreIPOption @@ -190,7 +190,7 @@ func (g *geoLite2ASNCSV) process(file string, entries map[string]*lib.Entry) err } if len(record) < 2 { - return fmt.Errorf("❌ [type %s | action %s] invalid record: %v", typeASNCSV, g.Action, record) + return fmt.Errorf("❌ [type %s | action %s] invalid record: %v", g.Type, g.Action, record) } if listArr, found := g.Want[strings.TrimSpace(record[1])]; found { diff --git a/plugin/maxmind/country_csv.go b/plugin/maxmind/country_csv.go index 090de13a..eb538dec 100644 --- a/plugin/maxmind/country_csv.go +++ b/plugin/maxmind/country_csv.go @@ -123,7 +123,7 @@ func (g *geoLite2CountryCSV) Input(container lib.Container) (lib.Container, erro } if len(entries) == 0 { - return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", typeCountryCSV, g.Action) + return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", g.Type, g.Action) } var ignoreIPType lib.IgnoreIPOption @@ -176,7 +176,7 @@ func (g *geoLite2CountryCSV) getCountryCode() (map[string]string, error) { ccMap := make(map[string]string) for _, line := range lines[1:] { if len(line) < 5 { - return nil, fmt.Errorf("❌ [type %s | action %s] invalid record: %v", typeCountryCSV, g.Action, line) + return nil, fmt.Errorf("❌ [type %s | action %s] invalid record: %v", g.Type, g.Action, line) } id := strings.TrimSpace(line[0]) @@ -193,7 +193,7 @@ func (g *geoLite2CountryCSV) getCountryCode() (map[string]string, error) { } if len(ccMap) == 0 { - return nil, fmt.Errorf("❌ [type %s | action %s] invalid country code data", typeCountryCSV, g.Action) + return nil, fmt.Errorf("❌ [type %s | action %s] invalid country code data", g.Type, g.Action) } return ccMap, nil @@ -201,7 +201,7 @@ func (g *geoLite2CountryCSV) getCountryCode() (map[string]string, error) { func (g *geoLite2CountryCSV) process(file string, ccMap map[string]string, entries map[string]*lib.Entry) error { if len(ccMap) == 0 { - return fmt.Errorf("❌ [type %s | action %s] invalid country code data", typeCountryCSV, g.Action) + return fmt.Errorf("❌ [type %s | action %s] invalid country code data", g.Type, g.Action) } if entries == nil { entries = make(map[string]*lib.Entry, len(ccMap)) @@ -234,7 +234,7 @@ func (g *geoLite2CountryCSV) process(file string, ccMap map[string]string, entri } if len(record) < 4 { - return fmt.Errorf("❌ [type %s | action %s] invalid record: %v", typeCountryCSV, g.Action, record) + return fmt.Errorf("❌ [type %s | action %s] invalid record: %v", g.Type, g.Action, record) } ccID := "" diff --git a/plugin/maxmind/mmdb_in.go b/plugin/maxmind/mmdb_in.go index 3ee1eacb..fc891c7a 100644 --- a/plugin/maxmind/mmdb_in.go +++ b/plugin/maxmind/mmdb_in.go @@ -105,7 +105,7 @@ func (m *maxmindMMDBIn) Input(container lib.Container) (lib.Container, error) { } if len(entries) == 0 { - return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", typeMaxmindMMDBIn, m.Action) + return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", m.Type, m.Action) } var ignoreIPType lib.IgnoreIPOption diff --git a/plugin/maxmind/mmdb_out.go b/plugin/maxmind/mmdb_out.go index e42ea02d..964971d7 100644 --- a/plugin/maxmind/mmdb_out.go +++ b/plugin/maxmind/mmdb_out.go @@ -123,7 +123,7 @@ func (m *mmdbOut) Output(container lib.Container) error { return err } } else { - return fmt.Errorf("type %s | action %s failed to write file", m.Type, m.Action) + return fmt.Errorf("❌ [type %s | action %s] failed to write file", m.Type, m.Action) } return nil |
