Commit 1a2a0244 authored by George Goldberg's avatar George Goldberg Committed by Saturnino Abril

Other Packages: NewLocAppError -> NewAppError (#7283)

parent f6e0310b
...@@ -39,7 +39,7 @@ func manualTest(c *api.Context, w http.ResponseWriter, r *http.Request) { ...@@ -39,7 +39,7 @@ func manualTest(c *api.Context, w http.ResponseWriter, r *http.Request) {
// URL Parameters // URL Parameters
params, err := url.ParseQuery(r.URL.RawQuery) params, err := url.ParseQuery(r.URL.RawQuery)
if err != nil { if err != nil {
c.Err = model.NewLocAppError("/manual", "manaultesting.manual_test.parse.app_error", nil, "") c.Err = model.NewAppError("/manual", "manaultesting.manual_test.parse.app_error", nil, "", http.StatusBadRequest)
return return
} }
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
l4g "github.com/alecthomas/log4go" l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model" "github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils" "github.com/mattermost/platform/utils"
"net/http"
) )
const LINK_POST_TEXT = ` const LINK_POST_TEXT = `
...@@ -24,7 +25,7 @@ func testAutoLink(env TestEnvironment) *model.AppError { ...@@ -24,7 +25,7 @@ func testAutoLink(env TestEnvironment) *model.AppError {
l4g.Info(utils.T("manaultesting.test_autolink.info")) l4g.Info(utils.T("manaultesting.test_autolink.info"))
channelID, err := getChannelID(model.DEFAULT_CHANNEL, env.CreatedTeamId, env.CreatedUserId) channelID, err := getChannelID(model.DEFAULT_CHANNEL, env.CreatedTeamId, env.CreatedUserId)
if err != true { if err != true {
return model.NewLocAppError("/manualtest", "manaultesting.test_autolink.unable.app_error", nil, "") return model.NewAppError("/manualtest", "manaultesting.test_autolink.unable.app_error", nil, "", http.StatusInternalServerError)
} }
post := &model.Post{ post := &model.Post{
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"github.com/mattermost/platform/einterfaces" "github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model" "github.com/mattermost/platform/model"
"net/http"
) )
const ( const (
...@@ -179,14 +180,14 @@ func SaveConfig(fileName string, config *model.Config) *model.AppError { ...@@ -179,14 +180,14 @@ func SaveConfig(fileName string, config *model.Config) *model.AppError {
b, err := json.MarshalIndent(config, "", " ") b, err := json.MarshalIndent(config, "", " ")
if err != nil { if err != nil {
return model.NewLocAppError("SaveConfig", "utils.config.save_config.saving.app_error", return model.NewAppError("SaveConfig", "utils.config.save_config.saving.app_error",
map[string]interface{}{"Filename": fileName}, err.Error()) map[string]interface{}{"Filename": fileName}, err.Error(), http.StatusBadRequest)
} }
err = ioutil.WriteFile(fileName, b, 0644) err = ioutil.WriteFile(fileName, b, 0644)
if err != nil { if err != nil {
return model.NewLocAppError("SaveConfig", "utils.config.save_config.saving.app_error", return model.NewAppError("SaveConfig", "utils.config.save_config.saving.app_error",
map[string]interface{}{"Filename": fileName}, err.Error()) map[string]interface{}{"Filename": fileName}, err.Error(), http.StatusInternalServerError)
} }
return nil return nil
...@@ -592,12 +593,12 @@ func ValidateLocales(cfg *model.Config) *model.AppError { ...@@ -592,12 +593,12 @@ func ValidateLocales(cfg *model.Config) *model.AppError {
locales := GetSupportedLocales() locales := GetSupportedLocales()
if _, ok := locales[*cfg.LocalizationSettings.DefaultServerLocale]; !ok { if _, ok := locales[*cfg.LocalizationSettings.DefaultServerLocale]; !ok {
*cfg.LocalizationSettings.DefaultServerLocale = model.DEFAULT_LOCALE *cfg.LocalizationSettings.DefaultServerLocale = model.DEFAULT_LOCALE
err = model.NewLocAppError("ValidateLocales", "utils.config.supported_server_locale.app_error", nil, "") err = model.NewAppError("ValidateLocales", "utils.config.supported_server_locale.app_error", nil, "", http.StatusBadRequest)
} }
if _, ok := locales[*cfg.LocalizationSettings.DefaultClientLocale]; !ok { if _, ok := locales[*cfg.LocalizationSettings.DefaultClientLocale]; !ok {
*cfg.LocalizationSettings.DefaultClientLocale = model.DEFAULT_LOCALE *cfg.LocalizationSettings.DefaultClientLocale = model.DEFAULT_LOCALE
err = model.NewLocAppError("ValidateLocales", "utils.config.supported_client_locale.app_error", nil, "") err = model.NewAppError("ValidateLocales", "utils.config.supported_client_locale.app_error", nil, "", http.StatusBadRequest)
} }
if len(*cfg.LocalizationSettings.AvailableLocales) > 0 { if len(*cfg.LocalizationSettings.AvailableLocales) > 0 {
...@@ -606,7 +607,7 @@ func ValidateLocales(cfg *model.Config) *model.AppError { ...@@ -606,7 +607,7 @@ func ValidateLocales(cfg *model.Config) *model.AppError {
if _, ok := locales[word]; !ok { if _, ok := locales[word]; !ok {
*cfg.LocalizationSettings.AvailableLocales = "" *cfg.LocalizationSettings.AvailableLocales = ""
isDefaultClientLocaleInAvailableLocales = true isDefaultClientLocaleInAvailableLocales = true
err = model.NewLocAppError("ValidateLocales", "utils.config.supported_available_locales.app_error", nil, "") err = model.NewAppError("ValidateLocales", "utils.config.supported_available_locales.app_error", nil, "", http.StatusBadRequest)
break break
} }
...@@ -619,7 +620,7 @@ func ValidateLocales(cfg *model.Config) *model.AppError { ...@@ -619,7 +620,7 @@ func ValidateLocales(cfg *model.Config) *model.AppError {
if !isDefaultClientLocaleInAvailableLocales { if !isDefaultClientLocaleInAvailableLocales {
availableLocales += "," + *cfg.LocalizationSettings.DefaultClientLocale availableLocales += "," + *cfg.LocalizationSettings.DefaultClientLocale
err = model.NewLocAppError("ValidateLocales", "utils.config.add_client_locale.app_error", nil, "") err = model.NewAppError("ValidateLocales", "utils.config.add_client_locale.app_error", nil, "", http.StatusBadRequest)
} }
*cfg.LocalizationSettings.AvailableLocales = strings.Join(RemoveDuplicatesFromStringArray(strings.Split(availableLocales, ",")), ",") *cfg.LocalizationSettings.AvailableLocales = strings.Join(RemoveDuplicatesFromStringArray(strings.Split(availableLocales, ",")), ",")
......
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
l4g "github.com/alecthomas/log4go" l4g "github.com/alecthomas/log4go"
"github.com/mattermost/html2text" "github.com/mattermost/html2text"
"github.com/mattermost/platform/model" "github.com/mattermost/platform/model"
"net/http"
) )
func encodeRFC2047Word(s string) string { func encodeRFC2047Word(s string) string {
...@@ -34,12 +35,12 @@ func connectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) { ...@@ -34,12 +35,12 @@ func connectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) {
conn, err = tls.Dial("tcp", config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort, tlsconfig) conn, err = tls.Dial("tcp", config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort, tlsconfig)
if err != nil { if err != nil {
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error()) return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
} else { } else {
conn, err = net.Dial("tcp", config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort) conn, err = net.Dial("tcp", config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
if err != nil { if err != nil {
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open.app_error", nil, err.Error()) return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.open.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
} }
...@@ -50,7 +51,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap ...@@ -50,7 +51,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap
c, err := smtp.NewClient(conn, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort) c, err := smtp.NewClient(conn, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
if err != nil { if err != nil {
l4g.Error(T("utils.mail.new_client.open.error"), err) l4g.Error(T("utils.mail.new_client.open.error"), err)
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error()) return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
hostname := GetHostnameFromSiteURL(*config.ServiceSettings.SiteURL) hostname := GetHostnameFromSiteURL(*config.ServiceSettings.SiteURL)
...@@ -58,7 +59,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap ...@@ -58,7 +59,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap
err := c.Hello(hostname) err := c.Hello(hostname)
if err != nil { if err != nil {
l4g.Error(T("utils.mail.new_client.helo.error"), err) l4g.Error(T("utils.mail.new_client.helo.error"), err)
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.helo.app_error", nil, err.Error()) return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.helo.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
} }
...@@ -74,7 +75,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap ...@@ -74,7 +75,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap
auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort) auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
if err = c.Auth(auth); err != nil { if err = c.Auth(auth); err != nil {
return nil, model.NewLocAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error()) return nil, model.NewAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
} }
return c, nil return c, nil
...@@ -148,25 +149,25 @@ func SendMailUsingConfig(to, subject, htmlBody string, config *model.Config) *mo ...@@ -148,25 +149,25 @@ func SendMailUsingConfig(to, subject, htmlBody string, config *model.Config) *mo
defer c.Close() defer c.Close()
if err := c.Mail(fromMail.Address); err != nil { if err := c.Mail(fromMail.Address); err != nil {
return model.NewLocAppError("SendMail", "utils.mail.send_mail.from_address.app_error", nil, err.Error()) return model.NewAppError("SendMail", "utils.mail.send_mail.from_address.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
if err := c.Rcpt(to); err != nil { if err := c.Rcpt(to); err != nil {
return model.NewLocAppError("SendMail", "utils.mail.send_mail.to_address.app_error", nil, err.Error()) return model.NewAppError("SendMail", "utils.mail.send_mail.to_address.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
w, err := c.Data() w, err := c.Data()
if err != nil { if err != nil {
return model.NewLocAppError("SendMail", "utils.mail.send_mail.msg_data.app_error", nil, err.Error()) return model.NewAppError("SendMail", "utils.mail.send_mail.msg_data.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
_, err = m.WriteTo(w) _, err = m.WriteTo(w)
if err != nil { if err != nil {
return model.NewLocAppError("SendMail", "utils.mail.send_mail.msg.app_error", nil, err.Error()) return model.NewAppError("SendMail", "utils.mail.send_mail.msg.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
err = w.Close() err = w.Close()
if err != nil { if err != nil {
return model.NewLocAppError("SendMail", "utils.mail.send_mail.close.app_error", nil, err.Error()) return model.NewAppError("SendMail", "utils.mail.send_mail.close.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
return nil return nil
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"github.com/mattermost/platform/app" "github.com/mattermost/platform/app"
"github.com/mattermost/platform/model" "github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils" "github.com/mattermost/platform/utils"
"net/http"
) )
func ApiWebSocketHandler(wh func(*model.WebSocketRequest) (map[string]interface{}, *model.AppError)) webSocketHandler { func ApiWebSocketHandler(wh func(*model.WebSocketRequest) (map[string]interface{}, *model.AppError)) webSocketHandler {
...@@ -54,5 +55,5 @@ func (wh webSocketHandler) ServeWebSocket(conn *app.WebConn, r *model.WebSocketR ...@@ -54,5 +55,5 @@ func (wh webSocketHandler) ServeWebSocket(conn *app.WebConn, r *model.WebSocketR
} }
func NewInvalidWebSocketParamError(action string, name string) *model.AppError { func NewInvalidWebSocketParamError(action string, name string) *model.AppError {
return model.NewLocAppError("/api/v3/users/websocket:"+action, "api.websocket_handler.invalid_param.app_error", map[string]interface{}{"Name": name}, "") return model.NewAppError("/api/v3/users/websocket:"+action, "api.websocket_handler.invalid_param.app_error", map[string]interface{}{"Name": name}, "", http.StatusBadRequest)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment