tgerr

package
v0.26.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 5 Imported by: 24

Documentation

Overview

Package tgerr implements helpers for error handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is

func Is(err error, tt ...string) bool

Is returns true if err type is t.

func IsCode

func IsCode(err error, code ...int) bool

IsCode returns true of error code is as provided.

Types

type Error

type Error struct {
	Code     int    // 420
	Message  string // FLOOD_WAIT_3
	Type     string // FLOOD_WAIT
	Argument int    // 3
}

Error represents RPC error returned as result to request.

func As

func As(err error) (rpcErr *Error, ok bool)

As extracts *Error from err if possible.

func AsType

func AsType(err error, t string) (rpcErr *Error, ok bool)

AsType returns *Error from err if rpc error type is t.

func New

func New(code int, msg string) *Error

New creates new *Error from code and message, extracting argument and type.

func (*Error) Error

func (e *Error) Error() string

func (*Error) IsCode

func (e *Error) IsCode(code int) bool

IsCode reports whether error Code is equal to code.

func (*Error) IsCodeOneOf

func (e *Error) IsCodeOneOf(codes ...int) bool

IsCodeOneOf returns true if error code is one of codes.

func (*Error) IsOneOf

func (e *Error) IsOneOf(tt ...string) bool

IsOneOf returns true if error type is in tt.

func (*Error) IsType

func (e *Error) IsType(t string) bool

IsType reports whether error has type t.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL