Source File
config_error.go
Belonging Package
github.com/gotd/td/telegram
package telegramimport ()// ConfigError is returned by Client.Run when the server rejects the// connection setup (initConnection) with an error that reconnecting cannot// fix, e.g. API_ID_INVALID, API_ID_PUBLISHED_FLOOD or// CONNECTION_API_ID_INVALID: the client is misconfigured.//// Use errors.As to match it.type ConfigError struct {// Err is the RPC error returned to initConnection.Err *tgerr.Error}// Error implements error.func ( *ConfigError) () string {return "connection setup rejected: " + .Err.Error()}// Unwrap returns the RPC error.func ( *ConfigError) () error {return .Err}// asConfigError returns ConfigError if err is a permanent error of// initConnection.//// These are 400 and 406 errors: the same request with the same parameters// fails again. Official clients send initConnection as a prefix of the// first real request, so such an error fails that request instead of// reconnecting.//// CONNECTION_NOT_INITED and CONNECTION_LAYER_INVALID are excluded: TDLib and// Telegram Desktop handle them by sending initConnection again. Errors of// IsAuthLost (e.g. AUTH_KEY_DUPLICATED) keep their own handling.func ( error) (*ConfigError, bool) {var *manager.InitErrorif !errors.As(, &) {return nil, false}, := tgerr.As(.Err)if ! {return nil, false}if .Code != 400 && .Code != 406 {return nil, false}if .IsOneOf("CONNECTION_NOT_INITED", "CONNECTION_LAYER_INVALID") || IsAuthLost() {return nil, false}return &ConfigError{Err: }, true}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |