package mt
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type RPCError struct {
ErrorCode int
ErrorMessage string
}
const RPCErrorTypeID = 0x2144ca19
var (
_ bin .Encoder = &RPCError {}
_ bin .Decoder = &RPCError {}
_ bin .BareEncoder = &RPCError {}
_ bin .BareDecoder = &RPCError {}
)
func (r *RPCError ) Zero () bool {
if r == nil {
return true
}
if !(r .ErrorCode == 0 ) {
return false
}
if !(r .ErrorMessage == "" ) {
return false
}
return true
}
func (r *RPCError ) String () string {
if r == nil {
return "RPCError(nil)"
}
type Alias RPCError
return fmt .Sprintf ("RPCError%+v" , Alias (*r ))
}
func (*RPCError ) TypeID () uint32 {
return RPCErrorTypeID
}
func (*RPCError ) TypeName () string {
return "rpc_error"
}
func (r *RPCError ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "rpc_error" ,
ID : RPCErrorTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ErrorCode" ,
SchemaName : "error_code" ,
},
{
Name : "ErrorMessage" ,
SchemaName : "error_message" ,
},
}
return typ
}
func (r *RPCError ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode rpc_error#2144ca19 as nil" )
}
b .PutID (RPCErrorTypeID )
return r .EncodeBare (b )
}
func (r *RPCError ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode rpc_error#2144ca19 as nil" )
}
b .PutInt (r .ErrorCode )
b .PutString (r .ErrorMessage )
return nil
}
func (r *RPCError ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode rpc_error#2144ca19 to nil" )
}
if err := b .ConsumeID (RPCErrorTypeID ); err != nil {
return fmt .Errorf ("unable to decode rpc_error#2144ca19: %w" , err )
}
return r .DecodeBare (b )
}
func (r *RPCError ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode rpc_error#2144ca19 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode rpc_error#2144ca19: field error_code: %w" , err )
}
r .ErrorCode = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode rpc_error#2144ca19: field error_message: %w" , err )
}
r .ErrorMessage = value
}
return nil
}
func (r *RPCError ) GetErrorCode () (value int ) {
if r == nil {
return
}
return r .ErrorCode
}
func (r *RPCError ) GetErrorMessage () (value string ) {
if r == nil {
return
}
return r .ErrorMessage
}
The pages are generated with Golds v0.6.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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .