remove "panic()" as much as posible from code (#682)

This commit is contained in:
6543
2022-01-09 23:27:30 +01:00
committed by GitHub
parent 6eecfa4b88
commit 5a120db69d
3 changed files with 12 additions and 8 deletions

View File

@@ -213,13 +213,13 @@ func (t *Transport) transport() http.RoundTripper {
// AuthCodeURL returns a URL that the end-user should be redirected to,
// so that they may obtain an authorization code.
func (c *Config) AuthCodeURL(state string) string {
func (c *Config) AuthCodeURL(state string) (string, error) {
_url, err := url.Parse(c.AuthURL)
if err != nil {
panic("AuthURL malformed: " + err.Error())
return "", fmt.Errorf("AuthURL malformed: %v", err)
}
if err := _url.Query().Get("error"); err != "" {
panic("AuthURL contains error: " + err)
return "", fmt.Errorf("AuthURL contains error: %v", err)
}
q := url.Values{
"response_type": {"code"},
@@ -235,7 +235,7 @@ func (c *Config) AuthCodeURL(state string) string {
} else {
_url.RawQuery += "&" + q
}
return _url.String()
return _url.String(), nil
}
func condVal(v string) []string {