summaryrefslogtreecommitdiff
path: root/plugin/plaintext
diff options
context:
space:
mode:
authorLoyalsoldier <[email protected]>2024-08-31 12:34:38 +0800
committerLoyalsoldier <[email protected]>2024-08-31 12:34:38 +0800
commit1e4cb746b9ca67b9d9dabdc65f42f495eb4cfbcd (patch)
treeee3de1a60416c7f56dcc99a2cf7715b9b8f4e5a2 /plugin/plaintext
parentdeff06ac0f59751bb9857bc7d645b756b6133ddf (diff)
Chore: make error messages consistent across formats
Diffstat (limited to 'plugin/plaintext')
-rw-r--r--plugin/plaintext/common_in.go2
-rw-r--r--plugin/plaintext/text_in.go12
2 files changed, 7 insertions, 7 deletions
diff --git a/plugin/plaintext/common_in.go b/plugin/plaintext/common_in.go
index fbaf21ff..06032c9d 100644
--- a/plugin/plaintext/common_in.go
+++ b/plugin/plaintext/common_in.go
@@ -200,7 +200,7 @@ func (t *textIn) scanFileForJSONIn(reader io.Reader, entry *lib.Entry) error {
}
if !gjson.ValidBytes(data) {
- return fmt.Errorf("invalid JSON data")
+ return fmt.Errorf("❌ [type %s | action %s] invalid JSON data", t.Type, t.Action)
}
// JSON Path syntax:
diff --git a/plugin/plaintext/text_in.go b/plugin/plaintext/text_in.go
index 9bc0d73f..68d60eaa 100644
--- a/plugin/plaintext/text_in.go
+++ b/plugin/plaintext/text_in.go
@@ -55,7 +55,7 @@ func newTextIn(iType string, action lib.Action, data json.RawMessage) (lib.Input
}
if iType == typeJSONIn && len(tmp.JSONPath) == 0 {
- return nil, fmt.Errorf("❌ [type %s | action %s] missing jsonPath", typeJSONIn, action)
+ return nil, fmt.Errorf("❌ [type %s | action %s] missing jsonPath", iType, action)
}
if tmp.InputDir == "" {
@@ -131,7 +131,7 @@ func (t *textIn) Input(container lib.Container) (lib.Container, error) {
err = t.appendIPOrCIDR(t.IPOrCIDR, t.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 or ipOrCIDR", t.Type, t.Action)
}
if err != nil {
@@ -147,7 +147,7 @@ func (t *textIn) Input(container lib.Container) (lib.Container, error) {
}
if len(entries) == 0 {
- return nil, fmt.Errorf("type %s | action %s no entry is generated", t.Type, t.Action)
+ return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", t.Type, t.Action)
}
for _, entry := range entries {
@@ -197,7 +197,7 @@ func (t *textIn) 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", t.Type, t.Action, entryName)
}
// remove file extension but not hidden files of which filename starts with "."
@@ -213,7 +213,7 @@ func (t *textIn) walkLocalFile(path, name string, entries map[string]*lib.Entry)
return nil
}
if _, found := entries[entryName]; found {
- return fmt.Errorf("found duplicated list %s", entryName)
+ return fmt.Errorf("❌ [type %s | action %s] found duplicated list %s", t.Type, t.Action, entryName)
}
entry := lib.NewEntry(entryName)
@@ -239,7 +239,7 @@ func (t *textIn) 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", t.Type, t.Action, url, resp.StatusCode)
}
name = strings.ToUpper(name)