Procházet zdrojové kódy

Merge pull request #253 from 9seconds/cannot-dial-err

More correct error if no addresses are found
tags/v2.1.5^2
Sergey Arkhipov před 4 roky
rodič
revize
6e447b1d59
Žádný účet není propojen s e-mailovou adresou tvůrce revize

+ 3
- 0
mtglib/internal/telegram/init.go Zobrazit soubor

@@ -2,10 +2,13 @@ package telegram
2 2
 
3 3
 import (
4 4
 	"context"
5
+	"errors"
5 6
 
6 7
 	"github.com/9seconds/mtg/v2/essentials"
7 8
 )
8 9
 
10
+var ErrNoAddresses = errors.New("no addresses")
11
+
9 12
 type preferIP uint8
10 13
 
11 14
 const (

+ 3
- 4
mtglib/internal/telegram/telegram.go Zobrazit soubor

@@ -28,10 +28,9 @@ func (t Telegram) Dial(ctx context.Context, dc int) (essentials.Conn, error) {
28 28
 		addresses = append(t.pool.getV6(dc), t.pool.getV4(dc)...)
29 29
 	}
30 30
 
31
-	var (
32
-		conn essentials.Conn
33
-		err  error
34
-	)
31
+	var conn essentials.Conn
32
+
33
+	err := ErrNoAddresses
35 34
 
36 35
 	for _, v := range addresses {
37 36
 		conn, err = t.dialer.DialContext(ctx, v.network, v.address)

Načítá se…
Zrušit
Uložit