forked from TrueCloudLab/frostfs-sdk-go
client: Replace panics with errors in dial
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
This commit is contained in:
parent
f9d740487a
commit
ef887b3ab1
2 changed files with 6 additions and 3 deletions
|
@ -77,12 +77,12 @@ func (c *Client) Init(prm PrmInit) {
|
|||
// See also Init / Close.
|
||||
func (c *Client) Dial(prm PrmDial) error {
|
||||
if prm.endpoint == "" {
|
||||
panic("server address is unset or empty")
|
||||
return ErrMissingServer
|
||||
}
|
||||
|
||||
if prm.timeoutDialSet {
|
||||
if prm.timeoutDial <= 0 {
|
||||
panic("non-positive timeout")
|
||||
return ErrNonPositiveTimeout
|
||||
}
|
||||
} else {
|
||||
prm.timeoutDial = 5 * time.Second
|
||||
|
@ -90,7 +90,7 @@ func (c *Client) Dial(prm PrmDial) error {
|
|||
|
||||
if prm.streamTimeoutSet {
|
||||
if prm.streamTimeout <= 0 {
|
||||
panic("non-positive timeout")
|
||||
return ErrNonPositiveTimeout
|
||||
}
|
||||
} else {
|
||||
prm.streamTimeout = 10 * time.Second
|
||||
|
|
|
@ -6,6 +6,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
ErrMissingServer = errors.New("server address is unset or empty")
|
||||
ErrNonPositiveTimeout = errors.New("non-positive timeout")
|
||||
|
||||
ErrMissingContainer = errors.New("missing container")
|
||||
ErrMissingObject = errors.New("missing object")
|
||||
ErrMissingAccount = errors.New("missing account")
|
||||
|
|
Loading…
Reference in a new issue