diff options
author | delvh <leon@kske.dev> | 2022-10-24 21:29:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 20:29:17 +0100 |
commit | 0ebb45cfe7606adf021ad359d6fbfcefc54360a5 (patch) | |
tree | 541b75d083213e93bbbfadbdc5d560c739543903 /models/repo/upload.go | |
parent | 7c11a73833f3aa9783015e5e13871d3c298d3ef6 (diff) | |
download | gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.tar.gz gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.zip |
Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)
Found using
`find . -type f -name '*.go' -print -exec vim {} -c
':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;`
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models/repo/upload.go')
-rw-r--r-- | models/repo/upload.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/models/repo/upload.go b/models/repo/upload.go index e3ce7e458f..e115c8e50e 100644 --- a/models/repo/upload.go +++ b/models/repo/upload.go @@ -70,19 +70,19 @@ func NewUpload(name string, buf []byte, file multipart.File) (_ *Upload, err err localPath := upload.LocalPath() if err = os.MkdirAll(path.Dir(localPath), os.ModePerm); err != nil { - return nil, fmt.Errorf("MkdirAll: %v", err) + return nil, fmt.Errorf("MkdirAll: %w", err) } fw, err := os.Create(localPath) if err != nil { - return nil, fmt.Errorf("Create: %v", err) + return nil, fmt.Errorf("Create: %w", err) } defer fw.Close() if _, err = fw.Write(buf); err != nil { - return nil, fmt.Errorf("Write: %v", err) + return nil, fmt.Errorf("Write: %w", err) } else if _, err = io.Copy(fw, file); err != nil { - return nil, fmt.Errorf("Copy: %v", err) + return nil, fmt.Errorf("Copy: %w", err) } if _, err := db.GetEngine(db.DefaultContext).Insert(upload); err != nil { @@ -134,7 +134,7 @@ func DeleteUploads(uploads ...*Upload) (err error) { if _, err = db.GetEngine(ctx). In("id", ids). Delete(new(Upload)); err != nil { - return fmt.Errorf("delete uploads: %v", err) + return fmt.Errorf("delete uploads: %w", err) } if err = committer.Commit(); err != nil { @@ -152,7 +152,7 @@ func DeleteUploads(uploads ...*Upload) (err error) { } if err := util.Remove(localPath); err != nil { - return fmt.Errorf("remove upload: %v", err) + return fmt.Errorf("remove upload: %w", err) } } @@ -166,11 +166,11 @@ func DeleteUploadByUUID(uuid string) error { if IsErrUploadNotExist(err) { return nil } - return fmt.Errorf("GetUploadByUUID: %v", err) + return fmt.Errorf("GetUploadByUUID: %w", err) } if err := DeleteUploads(upload); err != nil { - return fmt.Errorf("DeleteUpload: %v", err) + return fmt.Errorf("DeleteUpload: %w", err) } return nil |