Skip to content

Commit

Permalink
fail early
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaarbonel committed Oct 2, 2024
1 parent df06ee4 commit e84e476
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ func WithBaseUrl(baseURL string) ClientOption {
// is retrieved from STREAM_KEY and the secret from STREAM_SECRET
// environmental variables.
func NewClientFromEnvVars(options ...ClientOption) (*Client, error) {
return NewClient(os.Getenv("STREAM_API_KEY"), os.Getenv("STREAM_API_SECRET"), options...)
apiKey := os.Getenv("STREAM_API_KEY")
if apiKey == "" {
return nil, errors.New("STREAM_API_KEY is empty")
}
apiSecret := os.Getenv("STREAM_API_SECRET")
if apiSecret == "" {
return nil, errors.New("STREAM_API_SECRET is empty")
}
return NewClient(apiKey, apiSecret, options...)
}

// NewClient creates new stream chat api client.
Expand Down

0 comments on commit e84e476

Please sign in to comment.