summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-17 10:31:21 -0500
committerGitHub <noreply@github.com>2017-02-17 10:31:21 -0500
commit91fe8bb2c0d520f13269b2eadc2717a5ec4eea1c (patch)
tree088fc7015274975c4f1494a5b5afe72af84b6966 /store
parent4e7dbc3bb0e93bafa684594b19c5648dc030ee17 (diff)
downloadchat-91fe8bb2c0d520f13269b2eadc2717a5ec4eea1c.tar.gz
chat-91fe8bb2c0d520f13269b2eadc2717a5ec4eea1c.tar.bz2
chat-91fe8bb2c0d520f13269b2eadc2717a5ec4eea1c.zip
Implement upload and get file endpoints for APIv4 (#5396)
* Implement POST /files endpoint for APIv4 * Implement GET /files/{file_id} endpoint for APIv4
Diffstat (limited to 'store')
-rw-r--r--store/sql_file_info_store.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/store/sql_file_info_store.go b/store/sql_file_info_store.go
index c29ac461e..467ae39aa 100644
--- a/store/sql_file_info_store.go
+++ b/store/sql_file_info_store.go
@@ -3,6 +3,9 @@
package store
import (
+ "database/sql"
+ "net/http"
+
"github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
@@ -91,7 +94,11 @@ func (fs SqlFileInfoStore) Get(id string) StoreChannel {
WHERE
Id = :Id
AND DeleteAt = 0`, map[string]interface{}{"Id": id}); err != nil {
- result.Err = model.NewLocAppError("SqlFileInfoStore.Get", "store.sql_file_info.get.app_error", nil, "id="+id+", "+err.Error())
+ if err == sql.ErrNoRows {
+ result.Err = model.NewAppError("SqlFileInfoStore.Get", "store.sql_file_info.get.app_error", nil, "id="+id+", "+err.Error(), http.StatusNotFound)
+ } else {
+ result.Err = model.NewLocAppError("SqlFileInfoStore.Get", "store.sql_file_info.get.app_error", nil, "id="+id+", "+err.Error())
+ }
} else {
result.Data = info
}