|
|
@ -50,6 +50,7 @@ var errorRx = regexp.MustCompile(`{.+"error_code":(\d+),"description":"(.+)"}`)
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
// General errors
|
|
|
|
// General errors
|
|
|
|
ErrUnauthorized = NewAPIError(401, "Unauthorized")
|
|
|
|
ErrUnauthorized = NewAPIError(401, "Unauthorized")
|
|
|
|
|
|
|
|
ErrNotStartedByUser = NewAPIError(403, "Forbidden: bot can't initiate conversation with a user")
|
|
|
|
ErrBlockedByUser = NewAPIError(401, "Forbidden: bot was blocked by the user")
|
|
|
|
ErrBlockedByUser = NewAPIError(401, "Forbidden: bot was blocked by the user")
|
|
|
|
ErrUserIsDeactivated = NewAPIError(401, "Forbidden: user is deactivated")
|
|
|
|
ErrUserIsDeactivated = NewAPIError(401, "Forbidden: user is deactivated")
|
|
|
|
ErrNotFound = NewAPIError(404, "Not Found")
|
|
|
|
ErrNotFound = NewAPIError(404, "Not Found")
|
|
|
@ -97,6 +98,8 @@ func ErrByDescription(s string) error {
|
|
|
|
switch s {
|
|
|
|
switch s {
|
|
|
|
case ErrUnauthorized.ʔ():
|
|
|
|
case ErrUnauthorized.ʔ():
|
|
|
|
return ErrUnauthorized
|
|
|
|
return ErrUnauthorized
|
|
|
|
|
|
|
|
case ErrNotStartedByUser.ʔ():
|
|
|
|
|
|
|
|
return ErrNotStartedByUser
|
|
|
|
case ErrNotFound.ʔ():
|
|
|
|
case ErrNotFound.ʔ():
|
|
|
|
return ErrNotFound
|
|
|
|
return ErrNotFound
|
|
|
|
case ErrUserIsDeactivated.ʔ():
|
|
|
|
case ErrUserIsDeactivated.ʔ():
|
|
|
|