on main help sign in
Revert "refactor(tidy): remove nested if and else block"

This reverts commit a6e99fff52b4ab105df91f595a6e94ff3e8bd2cb.

commit96af7826dca69ee6f33a76d27cfa70793f1c1660 authorkujtimiihoxha <kujtimii.h@gmail.com> dateFri 19 Sep 2025, 10:50 (1 year ago) parent5811c4a
1 file changed+9−6
internal/config/config.go+9−6
internal/config/config.go+9−6
@@ -546,12 +546,15 @@ func (c *ProviderConfig) TestConnection(resolver VariableResolver) error {
546546 if err != nil {
547547 return fmt.Errorf("failed to create request for provider %s: %w", c.ID, err)
548548 }
549− if c.ID == string(catwalk.InferenceProviderZAI) && b.StatusCode == http.StatusUnauthorized {
550− // for z.ai just check if the http response is not 401
551− return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
552− }
553− if b.StatusCode != http.StatusOK {
554− return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
549+ if c.ID == string(catwalk.InferenceProviderZAI) {
550+ if b.StatusCode == http.StatusUnauthorized {
551+ // for z.ai just check if the http response is not 401
552+ return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
553+ }
554+ } else {
555+ if b.StatusCode != http.StatusOK {
556+ return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
557+ }
555558 }
556559 _ = b.Body.Close()
557560 return nil