summaryrefslogtreecommitdiffstats
path: root/model/file_info.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-09-15 13:32:11 +0100
committerJoram Wilander <jwawilander@gmail.com>2017-09-15 08:32:11 -0400
commit2be5577b88e5ff85a98b0a2b3e3a43b90cc99c6d (patch)
tree513dee966bfa8d3810ddf631df90270acd342e4f /model/file_info.go
parent600beb5af3e35fd82a2b06995b67629d08fe0fe3 (diff)
downloadchat-2be5577b88e5ff85a98b0a2b3e3a43b90cc99c6d.tar.gz
chat-2be5577b88e5ff85a98b0a2b3e3a43b90cc99c6d.tar.bz2
chat-2be5577b88e5ff85a98b0a2b3e3a43b90cc99c6d.zip
Model: NewLocAppError -> NewAppError (#7450)
Diffstat (limited to 'model/file_info.go')
-rw-r--r--model/file_info.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/model/file_info.go b/model/file_info.go
index 3071e6d4b..0ee2c50d8 100644
--- a/model/file_info.go
+++ b/model/file_info.go
@@ -10,6 +10,7 @@ import (
"image/gif"
"io"
"mime"
+ "net/http"
"path/filepath"
"strings"
)
@@ -89,27 +90,27 @@ func (o *FileInfo) PreSave() {
func (o *FileInfo) IsValid() *AppError {
if len(o.Id) != 26 {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.id.app_error", nil, "")
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}
if len(o.CreatorId) != 26 {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.user_id.app_error", nil, "id="+o.Id)
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.user_id.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if len(o.PostId) != 0 && len(o.PostId) != 26 {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.post_id.app_error", nil, "id="+o.Id)
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.post_id.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if o.CreateAt == 0 {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.create_at.app_error", nil, "id="+o.Id)
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if o.UpdateAt == 0 {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.update_at.app_error", nil, "id="+o.Id)
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if o.Path == "" {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.path.app_error", nil, "id="+o.Id)
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.path.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
return nil
@@ -147,7 +148,7 @@ func GetInfoForBytes(name string, data []byte) (*FileInfo, *AppError) {
if gifConfig, err := gif.DecodeAll(bytes.NewReader(data)); err != nil {
// Still return the rest of the info even though it doesn't appear to be an actual gif
info.HasPreviewImage = true
- err = NewLocAppError("GetInfoForBytes", "model.file_info.get.gif.app_error", nil, "name="+name)
+ err = NewAppError("GetInfoForBytes", "model.file_info.get.gif.app_error", nil, "name="+name, http.StatusBadRequest)
} else {
info.HasPreviewImage = len(gifConfig.Image) == 1
}