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/mihomo | |
| parent | deff06ac0f59751bb9857bc7d645b756b6133ddf (diff) | |
Chore: make error messages consistent across formats
Diffstat (limited to 'plugin/mihomo')
| -rw-r--r-- | plugin/mihomo/mrs_in.go | 12 | ||||
| -rw-r--r-- | plugin/mihomo/mrs_out.go | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/plugin/mihomo/mrs_in.go b/plugin/mihomo/mrs_in.go index 4976e071..a3ab9364 100644 --- a/plugin/mihomo/mrs_in.go +++ b/plugin/mihomo/mrs_in.go @@ -50,11 +50,11 @@ func newMRSIn(action lib.Action, data json.RawMessage) (lib.InputConverter, erro } if tmp.Name == "" && tmp.URI == "" && tmp.InputDir == "" { - return nil, fmt.Errorf("type %s | action %s missing inputdir or name or uri", typeMRSIn, action) + return nil, fmt.Errorf("❌ [type %s | action %s] missing inputDir or name or uri", typeMRSIn, action) } if (tmp.Name != "" && tmp.URI == "") || (tmp.Name == "" && tmp.URI != "") { - return nil, fmt.Errorf("type %s | action %s name & uri must be specified together", typeMRSIn, action) + return nil, fmt.Errorf("❌ [type %s | action %s] name & uri must be specified together", typeMRSIn, action) } // Filter want list @@ -115,7 +115,7 @@ func (m *mrsIn) Input(container lib.Container) (lib.Container, error) { err = m.walkLocalFile(m.URI, m.Name, entries) } default: - return nil, fmt.Errorf("config missing argument inputDir or name or uri") + return nil, fmt.Errorf("❌ [type %s | action %s] config missing argument inputDir or name or uri", m.Type, m.Action) } if err != nil { @@ -181,7 +181,7 @@ func (m *mrsIn) walkLocalFile(path, name string, entries map[string]*lib.Entry) // check filename if !regexp.MustCompile(`^[a-zA-Z0-9_.\-]+$`).MatchString(entryName) { - return fmt.Errorf("filename %s cannot be entry name, please remove special characters in it", entryName) + return fmt.Errorf("❌ [type %s | action %s] filename %s cannot be entry name, please remove special characters in it", m.Type, m.Action, entryName) } // remove file extension but not hidden files of which filename starts with "." @@ -193,7 +193,7 @@ func (m *mrsIn) walkLocalFile(path, name string, entries map[string]*lib.Entry) entryName = strings.ToUpper(entryName) if _, found := entries[entryName]; found { - return fmt.Errorf("found duplicated list %s", entryName) + return fmt.Errorf("❌ [type %s | action %s] found duplicated list %s", m.Type, m.Action, entryName) } file, err := os.Open(path) @@ -217,7 +217,7 @@ func (m *mrsIn) walkRemoteFile(url, name string, entries map[string]*lib.Entry) defer resp.Body.Close() if resp.StatusCode != 200 { - return fmt.Errorf("failed to get remote file %s, http status code %d", url, resp.StatusCode) + return fmt.Errorf("❌ [type %s | action %s] failed to get remote file %s, http status code %d", m.Type, m.Action, url, resp.StatusCode) } if err := m.generateEntries(name, resp.Body, entries); err != nil { diff --git a/plugin/mihomo/mrs_out.go b/plugin/mihomo/mrs_out.go index 14d48428..fe9480da 100644 --- a/plugin/mihomo/mrs_out.go +++ b/plugin/mihomo/mrs_out.go @@ -148,7 +148,7 @@ func (m *mrsOut) generate(entry *lib.Entry) error { } if len(ipRanges) == 0 { - return fmt.Errorf("entry %s has no CIDR", entry.GetName()) + return fmt.Errorf("❌ [type %s | action %s] entry %s has no CIDR", m.Type, m.Action, entry.GetName()) } filename := strings.ToLower(entry.GetName()) + ".mrs" |
