From 7392bb495b9d99f3dd202dfaffeabce32c6a8290 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Thu, 24 Aug 2017 22:56:31 +0200 Subject: [PATCH] refactor --- common/protocol/user.go | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/common/protocol/user.go b/common/protocol/user.go index 7941cbd7..3ae45019 100644 --- a/common/protocol/user.go +++ b/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: