Skip to content

Commit e19a4b1

Browse files
committed
fix nits
1 parent d11f7c8 commit e19a4b1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

services/attachment/attachment.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ type ErrAttachmentSizeExceed struct {
4343
Size int64
4444
}
4545

46-
func (e *ErrAttachmentSizeExceed) Error() string {
46+
func (e ErrAttachmentSizeExceed) Error() string {
4747
return fmt.Sprintf("attachment size %d exceed limit %d", e.Size, e.MaxSize)
4848
}
4949

5050
func IsErrAttachmentSizeExceed(err error) bool {
51-
_, ok := err.(*ErrAttachmentSizeExceed)
51+
_, ok := err.(ErrAttachmentSizeExceed)
5252
return ok
5353
}
5454

55+
func (err ErrAttachmentSizeExceed) Unwrap() error {
56+
return util.ErrInvalidArgument
57+
}
58+
5559
// UploadAttachment upload new attachment into storage and update database
5660
func UploadAttachment(ctx context.Context, file io.Reader, allowedTypes string, maxFileSize, fileSize int64, attach *repo_model.Attachment) (*repo_model.Attachment, error) {
5761
buf := make([]byte, 1024)
@@ -63,7 +67,7 @@ func UploadAttachment(ctx context.Context, file io.Reader, allowedTypes string,
6367
}
6468

6569
if maxFileSize >= 0 && fileSize > (maxFileSize) {
66-
return nil, &ErrAttachmentSizeExceed{MaxSize: maxFileSize, Size: fileSize}
70+
return nil, ErrAttachmentSizeExceed{MaxSize: maxFileSize, Size: fileSize}
6771
}
6872

6973
return NewAttachment(ctx, attach, io.MultiReader(bytes.NewReader(buf), file), fileSize)

0 commit comments

Comments
 (0)