summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/admin.go4
-rw-r--r--api/license.go5
-rw-r--r--api/user.go2
-rw-r--r--i18n/en.json12
-rw-r--r--model/utils.go10
-rw-r--r--model/utils_test.go2
6 files changed, 19 insertions, 16 deletions
diff --git a/api/admin.go b/api/admin.go
index b19772fdf..0ea6341e2 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -73,7 +73,9 @@ func logClient(c *Context, w http.ResponseWriter, r *http.Request) {
}
if lvl == "ERROR" {
- err := model.NewAppError("client", msg, "")
+ err := &model.AppError{}
+ err.Message = msg
+ err.Where = "client"
c.LogError(err)
}
diff --git a/api/license.go b/api/license.go
index 5c602a68e..4077c0e46 100644
--- a/api/license.go
+++ b/api/license.go
@@ -5,7 +5,6 @@ package api
import (
"bytes"
- "fmt"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
@@ -65,13 +64,13 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
license = model.LicenseFromJson(strings.NewReader(licenseStr))
if result := <-Srv.Store.User().AnalyticsUniqueUserCount(""); result.Err != nil {
- c.Err = model.NewAppError("addLicense", "Unable to count total unique users.", fmt.Sprintf("err=%v", result.Err.Error()))
+ c.Err = model.NewLocAppError("addLicense", "api.license.add_license.invalid_count.app_error", nil, result.Err.Error())
return
} else {
uniqueUserCount := result.Data.(int64)
if uniqueUserCount > int64(*license.Features.Users) {
- c.Err = model.NewAppError("addLicense", fmt.Sprintf("This license only supports %d users, when your system has %d unique users. Unique users are counted distinctly by email address. You can see total user count under Site Reports -> View Statistics.", *license.Features.Users, uniqueUserCount), "")
+ c.Err = model.NewLocAppError("addLicense", "api.license.add_license.unique_users.app_error", map[string]interface{}{"Users": *license.Features.Users, "Count": uniqueUserCount}, "")
return
}
}
diff --git a/api/user.go b/api/user.go
index ceaf1fc2d..6ad0f67ac 100644
--- a/api/user.go
+++ b/api/user.go
@@ -1157,7 +1157,7 @@ func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
path := "teams/" + c.Session.TeamId + "/users/" + c.Session.UserId + "/profile.png"
if err := writeFile(buf.Bytes(), path); err != nil {
- c.Err = model.NewAppError("uploadProfileImage", "Couldn't upload profile image", "")
+ c.Err = model.NewLocAppError("uploadProfileImage", "api.user.upload_profile_user.upload_profile.app_error", nil, "")
return
}
diff --git a/i18n/en.json b/i18n/en.json
index 14a2e3148..12741fc68 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -588,6 +588,14 @@
"translation": "Could not open license file"
},
{
+ "id": "api.license.add_license.invalid_count.app_error",
+ "translation": "Unable to count total unique users."
+ },
+ {
+ "id": "api.license.add_license.unique_users.app_error",
+ "translation": "This license only supports {{.Users}} users, when your system has {{.Count}} unique users. Unique users are counted distinctly by email address. You can see total user count under Site Reports -> View Statistics."
+ },
+ {
"id": "api.license.add_license.save.app_error",
"translation": "License did not save properly."
},
@@ -1544,6 +1552,10 @@
"translation": "Could not encode profile image"
},
{
+ "id": "api.user.upload_profile_user.upload_profile.app_error",
+ "translation": "Couldn't upload profile image"
+ },
+ {
"id": "api.user.upload_profile_user.no_file.app_error",
"translation": "No file under 'image' in request"
},
diff --git a/model/utils.go b/model/utils.go
index 719a2ad1b..695d4a0cb 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -71,16 +71,6 @@ func AppErrorFromJson(data io.Reader) *AppError {
}
}
-func NewAppError(where string, message string, details string) *AppError {
- ap := &AppError{}
- ap.Message = message
- ap.Where = where
- ap.DetailedError = details
- ap.StatusCode = 500
- ap.IsOAuth = false
- return ap
-}
-
func NewLocAppError(where string, id string, params map[string]interface{}, details string) *AppError {
ap := &AppError{}
ap.Id = id
diff --git a/model/utils_test.go b/model/utils_test.go
index b8eabe264..02a08d113 100644
--- a/model/utils_test.go
+++ b/model/utils_test.go
@@ -27,7 +27,7 @@ func TestRandomString(t *testing.T) {
}
func TestAppError(t *testing.T) {
- err := NewAppError("TestAppError", "message", "")
+ err := NewLocAppError("TestAppError", "message", nil, "")
json := err.ToJson()
rerr := AppErrorFromJson(strings.NewReader(json))
if err.Message != rerr.Message {