@@ -49,6 +49,9 @@ func (c *Config) Validate(requireApp bool) error {
4949 if c .APIEndpoint == "" {
5050 return ErrInvalidAPIEndpoint
5151 }
52+ if _ , err := url .ParseRequestURI (c .APIEndpoint ); err != nil {
53+ return ErrInvalidAPIEndpoint
54+ }
5255 if c .Timeout <= 0 {
5356 return ErrInvalidTimeout
5457 }
@@ -94,7 +97,7 @@ func New(cfg *Config) (*Client, error) {
9497 // make a request to the health check endpoint
9598 resp , err := httpClient .Do (r )
9699 if err != nil {
97- return nil , err
100+ return nil , ErrAPIUnavailable
98101 }
99102 defer resp .Body .Close ()
100103 // check if the response is OK
@@ -146,7 +149,7 @@ func (c *Client) NewAppID(name, redirectURI, secret string, sessionDuration time
146149 // make the request to the API
147150 res , err := c .httpClient .Do (req )
148151 if err != nil {
149- return nil , err
152+ return nil , ErrRequestAppID
150153 }
151154 // read the response data, it also checks if the response is OK and closes
152155 // the response body
@@ -186,7 +189,7 @@ func (c *Client) RequestToken(email string) error {
186189 // make the request to the API
187190 res , err := c .httpClient .Do (req )
188191 if err != nil {
189- return err
192+ return ErrAPIUnavailable
190193 }
191194 defer res .Body .Close ()
192195 // check if the response is OK
@@ -228,7 +231,7 @@ func (c *Client) VerifyToken(token *token.Token, email string) (bool, time.Time,
228231 // make the request to the API
229232 res , err := c .httpClient .Do (req )
230233 if err != nil {
231- return false , time.Time {}, err
234+ return false , time.Time {}, ErrAPIUnavailable
232235 }
233236 // decode the response data, it also checks if the response is OK and
234237 // closes the response body
0 commit comments