internal/gofix and fix error wrapping (#76)

This commit is contained in:
T. von Dein
2026-07-07 10:41:34 +02:00
parent f10366dbde
commit b8e0ee074c
28 changed files with 109 additions and 119 deletions

View File

@@ -94,7 +94,7 @@ func ApiRepl(conf *cfg.Config) error {
})
if err != nil {
return fmt.Errorf("failed to initialize readline lib: %s", err)
return fmt.Errorf("failed to initialize readline lib: %w", err)
}
for {
@@ -237,7 +237,7 @@ func CallAPI(conf *cfg.Config, verb, path, data string) ([]byte, error) {
// Read and print response
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %s", err)
return nil, fmt.Errorf("failed to read response body: %w", err)
}
return body, nil
@@ -261,7 +261,7 @@ func prettyfiJson(conf *cfg.Config, raw []byte) (string, error) {
var pretty bytes.Buffer
err := json.Indent(&pretty, raw, "", "\t")
if err != nil {
return "", fmt.Errorf("json parse error: %s", err)
return "", fmt.Errorf("json parse error: %w", err)
}
return pretty.String(), nil
@@ -295,7 +295,7 @@ func readJSON(input string) (string, error) {
check := map[string]any{}
err := json.Unmarshal([]byte(data), &check)
if err != nil {
return "", fmt.Errorf("error: input data is not proper JSON: %s", err)
return "", fmt.Errorf("error: input data is not proper JSON: %w", err)
}