wrap errors correctly

This commit is contained in:
2026-07-07 09:34:36 +02:00
parent 24038e36f7
commit 2f77c27715
22 changed files with 95 additions and 94 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)
}