github.com/tada-team/tdproto@v1.51.57/tdapi/err.go (about) 1 package tdapi 2 3 type Err string 4 5 const ( 6 Ok = Err("OK") 7 EmptyToken = Err("EMPTY_TOKEN") 8 EmptySession = Err("EMPTY_SESSION") 9 InvalidToken = Err("INVALID_TOKEN") 10 AccessDenied = Err("ACCESS_DENIED") 11 NotFound = Err("NOT_FOUND") 12 NotModified = Err("NOT_MODIFIED") 13 RateLimit = Err("RATE_LIMIT") 14 InternalServerError = Err("INTERNAL_SERVER_ERROR") 15 InvalidMethod = Err("INVALID_METHOD") 16 InvalidData = Err("INVALID_DATA") 17 AccountNotFound = Err("ACCOUNT_NOT_FOUND") 18 AccountSuspended = Err("ACCOUNT_SUSPENDED") 19 AccountBlocked = Err("ACCOUNT_BLOCKED") 20 NoEmptyWorkplaces = Err("NO_EMPTY_WORKPLACES") 21 ) 22 23 func (e Err) Error() string { return string(e) } 24 25 func (e Err) StatusCode() int { 26 switch e { 27 case NotModified: 28 return 304 29 case NoEmptyWorkplaces: 30 return 400 31 case EmptyToken, InvalidToken, EmptySession: 32 return 401 33 case AccessDenied: 34 return 403 35 case NotFound: 36 return 404 37 case RateLimit: 38 return 429 39 case InternalServerError: 40 return 500 41 case InvalidMethod: 42 return 405 43 case InvalidData: 44 return 422 45 case AccountNotFound, AccountBlocked: 46 return 451 47 case AccountSuspended: 48 return 402 49 default: 50 return 200 51 } 52 }