Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Aug 24, 2017
1 parent 1c2b6d9 commit 7392bb4
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions common/protocol/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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:
Expand Down

0 comments on commit 7392bb4

Please sign in to comment.