Skip to content

Commit 46f3690

Browse files
fix(client): return error on bad custom url instead of panic (#78)
1 parent 02740bc commit 46f3690

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

option/requestoption.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"bytes"
77
"fmt"
88
"io"
9-
"log"
109
"net/http"
1110
"net/url"
1211
"strings"
@@ -28,10 +27,11 @@ type RequestOption = requestconfig.RequestOption
2827
// For security reasons, ensure that the base URL is trusted.
2928
func WithBaseURL(base string) RequestOption {
3029
u, err := url.Parse(base)
31-
if err != nil {
32-
log.Fatalf("failed to parse BaseURL: %s\n", err)
33-
}
3430
return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {
31+
if err != nil {
32+
return fmt.Errorf("requestoption: WithBaseURL failed to parse url %s\n", err)
33+
}
34+
3535
if u.Path != "" && !strings.HasSuffix(u.Path, "/") {
3636
u.Path += "/"
3737
}

0 commit comments

Comments
 (0)