Advertisement
stuppid_bot

Untitled

Dec 14th, 2014
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.62 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. class ApiError(Exception):
  3.     def __init__(self, error_params):
  4.         self.code = error_params['error_code']
  5.         self.message = error_params['error_msg']
  6.         self.captcha_sid = error_params.get('captcha_sid')
  7.         self.captcha_img = error_params.get('captcha_img')
  8.         self.redirect_uri = error_params.get('redirect_uri')
  9.         params = {param['key']: param['value']
  10.                   for param in error_params['request_params']}
  11.         self.oauth = params.pop('oauth')
  12.         self.method = params.pop('method')
  13.         self.params = params
  14.  
  15.     def __str__(self):
  16.         return "[{}] {}".format(self.code, self.message)
  17.  
  18. # Специфические ошибки.
  19. class AuthorizationFailed(ApiError):
  20.     """User authorization failed"""
  21.     pass
  22.  
  23. class TooManyRequests(ApiError):
  24.     """Too many requests per second"""
  25.     pass
  26.  
  27. class FloodControl(ApiError):
  28.     """Flood control"""
  29.     pass
  30.  
  31. class InternalError(ApiError):
  32.     """Internal server error"""
  33.     pass
  34.  
  35. class CaptchaNeeded(ApiError):
  36.     """Captcha needed"""
  37.     pass
  38.  
  39. class AccessDenied(ApiError):
  40.     """Access denied"""
  41.     pass
  42.  
  43. class ValidationRequired(ApiError):
  44.     """Validation required"""
  45.     pass
  46.  
  47. class InvalidUserId(ApiError):
  48.     """Invalid user id"""
  49.     pass
  50.  
  51. class AlbumAccessDenied(ApiError):
  52.     """Access to album denied"""
  53.     pass
  54.  
  55. class AudioAccessDenied(ApiError):
  56.     """Access to audio denied"""
  57.     pass
  58.  
  59. class GroupAccessDenied(ApiError):
  60.     """Access to group denied"""
  61.     pass
  62.  
  63. class AlbumFull(ApiError):
  64.     """This album is full"""
  65.     pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement