River documentation

River documentation

  • Documentation
  • Blog

›Error Handling

User Authorization

  • User Authorization

Error Handling

  • Error Handling

PUSH-notifications

  • Handling PUSH-notifications

Handling Updates

  • Handling Updates

Pagination

  • Pagination

Message Drafts

  • Message Drafts

Encryption

  • Encryption

API methods

  • Available method list

Client Optimization

  • Client Optimization

Uploading and Downloading

  • Uploading and Downloading

Error Handling

When you are working with the API, you will be faced with some errors. Therefore, they must be handled on the client correctly.

We delineate an error by the parameters as follows:

Error Codes: A string literal in the form of /E[0-9]{2,}/, which summarizes the problem. For example, ErrCodeInvalid = "E01", ErrCodeTimeout = "E06", so on.

Error Codes

const (

ErrCodeInternal         = "E00"
ErrCodeInvalid          = "E01"
ErrCodeUnavailable      = "E02"
ErrCodeTooMany          = "E03"
ErrCodeTooFew           = "E04"
ErrCodeIncomplete       = "E05"
ErrCodeTimeout          = "E06"
ErrCodeAccess           = "E07"
ErrCodeAlreadyExists    = "E08"
ErrCodeBusy             = "E09"
ErrCodeOutOfRange       = "E10"
ErrCodePartiallyApplied = "E11"
ErrCodeExpired          = "E12"

)

Example:

E00 is when the error is happening the internal layers of sub-services of River, and the details will not be exposed to the user for security reason. i.e. if we get a database error, we do not expose it otherwise a malicious user may detect our database vendor or its version or ...

Error Items

It contains information on the type of error that occurred: for example, a data input error, encryption error, or server error. This is a required parameter.

const (

ErrItemPhone            = "PHONE"
ErrItemPhoneCode        = "PHONE_CODE"
ErrItemUserID           = "USER_ID"
ErrItemPeer             = "PEER"
ErrItemPeerType         = "PEER_TYPE"
ErrItemInput            = "INPUT"
ErrItemRequest          = "REQUEST"
ErrItemMessage          = "MESSAGE"
ErrItemMessageID        = "MESSAGE_ID"
ErrItemServer           = "SERVER"
ErrItemPq               = "PQ"
ErrItemEncryption       = "ENCRYPTION"
ErrItemRsaKey           = "RSA_KEY"
ErrItemProto            = "PROTO"
ErrItemDhKey            = "DH_KEY"
ErrItemSignIn           = "SIGN_IN"
ErrItemRandomID         = "RANDOM_ID"
ErrItemAccessHash       = "ACCESS_HASH"
ErrItemJobWorker        = "JOB_WORKER"
ErrItemAuth             = "AUTH"
ErrItemAuthID           = "AUTH_ID"
ErrItemUsername         = "USERNAME"
ErrItemChatText         = "CHAT_TEXT"
ErrItemGroupTitle       = "GROUP_TITLE"
ErrItemGroupID          = "GROUP_ID"
ErrItemGroup            = "GROUP"
ErrItemGroupMember      = "GROUP_MEMBER"
ErrItemUsers            = "USERS"
ErrItemRetractTime      = "RETRACT_TIME"
ErrItemBio              = "BIO"
ErrItemApi              = "API"
ErrItemLastAdmin        = "LAST_ADMIN"
ErrItemDeleteCreator    = "DELETE_CREATOR"
ErrItemFilePartID       = "FILE_PART_ID"
ErrItemFileParts        = "FILE_PARTS"
ErrItemFilePartSize     = "FILE_PART_SIZE"
ErrItemDeviceToken      = "DEVICE_TOKEN"
ErrItemDeviceModel      = "DEVICE_MODEL"
ErrItemDocument         = "DOCUMENT"
ErrItemToken            = "TOKEN"
ErrItemMedia            = "MEDIA"
ErrItemPinnedDialogs    = "PINNED_DIALOGS"
ErrItemSalt             = "SALT"
ErrItemCounter          = "COUNTER"
ErrItemAppUpdate        = "APP_UPDATE"
ErrItemBindUser         = "BIND_USER"
ErrItemActiveConnection = "ACTIVE_CONN"
ErrItemInputFile        = "INPUT_FILE"
ErrItemPhotoID          = "PHOTO_ID"
ErrItemBot              = "BOT"
ErrItemPhoto            = "PHOTO"
ErrItemMember           = "MEMBER"
ErrItemFeature          = "FEATURE"
ErrItemMarshal          = "MARSHAL"
ErrItemUnMarshal        = "UNMARSHAL"
ErrItemName             = "NAME"
ErrItemColour           = "COLOUR"
ErrItemLabelID          = "LABEL_ID"
ErrItemLabelName        = "LABEL_NAME"
ErrItemLabelColour      = "LABEL_COLOUR"
ErrItemLabel            = "LABEL"
ErrItemAlgorithm        = "ALGORITHM"
ErrItemAlgorithmData    = "ALGORITHM_DATA"
ErrItemPasswordHash     = "PASSWORD_HASH"
ErrItemPassword         = "PASSWORD"
ErrItemSrpB             = "SRP_B"
ErrItemLogin            = "LOGIN"
ErrItemSecurityQuestion = "SECURITY_QUESTION"
ErrItemSecurityAnswer   = "SECURITY_ANSWER"

)

Examples:

  • ErrCodeInvalid = "E01": ErrItemProEto = "PROTO" => if there is a problem in decoding bytes into a valid and expected protobuf object

  • ErrCodeUnavailable = "E02": ErrItemAccessHash = "ACCESS_HASH" => when client sends a wrong access hash

  • ErrCodeCodeInternal = “E00”: ErrItemUserID = “USERID” => if a user terminated all sessions

  • ErrCodeInternal = "E00": ErrItemServer = "SERVER" => if there is an unknown error in server

  • ErrCodeTooFew = "E04": ErrItemUsers = "USERS" => when a client requests to get a group of users but the server cannot find them in its datastore

← User AuthorizationHandling PUSH-notifications →
Copyright © 2020 RonakSoftwareGroup