Refactor error handling

This commit is contained in:
Tim Schubert 2023-11-18 15:53:50 +01:00
parent 44807299b1
commit 753021af5e
Signed by: dadada
SSH key fingerprint: SHA256:bFAjFH3hR8zRBaJjzQDjc3o4jqoq5EZ87l+KXEjxIz0
7 changed files with 108 additions and 80 deletions

View file

@ -12,7 +12,7 @@ import (
func download(
gitdir string,
url string,
) (string, error) {
) (padfile string, err error) {
res, err := http.Get(url + "/export/txt")
if err != nil {
return "", fmt.Errorf("Failed to get pad at %s: %w", url, err)
@ -20,7 +20,7 @@ func download(
defer res.Body.Close()
padfile := path.Base(url) + ".txt"
padfile = path.Base(url) + ".txt"
padpath := filepath.Join(gitdir, padfile)
out, err := os.Create(padpath)
@ -34,5 +34,5 @@ func download(
return "", fmt.Errorf("Skipping update of %s, because pad has likely been removed from %s", padfile, url)
}
return padfile, nil
return
}