From ef887b3ab18cc33128831cdb2ddc527e37ee0061 Mon Sep 17 00:00:00 2001 From: Evgenii Baidakov Date: Wed, 17 May 2023 14:11:33 +0400 Subject: [PATCH] client: Replace panics with errors in dial Signed-off-by: Evgenii Baidakov --- client/client.go | 6 +++--- client/errors.go | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/client.go b/client/client.go index 3571c1f..ce0c9ee 100644 --- a/client/client.go +++ b/client/client.go @@ -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 diff --git a/client/errors.go b/client/errors.go index c89eb3f..3b19fad 100644 --- a/client/errors.go +++ b/client/errors.go @@ -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")