Darien Raymond hace 8 años
padre
commit
7392bb495b
Se han modificado 1 ficheros con 7 adiciones y 13 borrados
  1. 7 13
      common/protocol/user.go

+ 7 - 13
common/protocol/user.go

@@ -2,18 +2,12 @@ package protocol
 
 import "time"
 
-var (
-	ErrAccountMissing     = newError("Account is not specified.")
-	ErrNonMessageType     = newError("Not a protobuf message.")
-	ErrUnknownAccountType = newError("Unknown account type.")
-)
-
-func (v *User) GetTypedAccount() (Account, error) {
-	if v.GetAccount() == nil {
-		return nil, ErrAccountMissing
+func (u *User) GetTypedAccount() (Account, error) {
+	if u.GetAccount() == nil {
+		return nil, newError("Account missing").AtWarning()
 	}
 
-	rawAccount, err := v.Account.GetInstance()
+	rawAccount, err := u.Account.GetInstance()
 	if err != nil {
 		return nil, err
 	}
@@ -23,12 +17,12 @@ func (v *User) GetTypedAccount() (Account, error) {
 	if account, ok := rawAccount.(Account); ok {
 		return account, nil
 	}
-	return nil, newError("Unknown account type: ", v.Account.Type)
+	return nil, newError("Unknown account type: ", u.Account.Type)
 }
 
-func (v *User) GetSettings() UserSettings {
+func (u *User) GetSettings() UserSettings {
 	settings := UserSettings{}
-	switch v.Level {
+	switch u.Level {
 	case 0:
 		settings.PayloadTimeout = time.Second * 30
 	case 1: