exceptions.py 1.1 KB

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. class BucketFullException(Exception):
  4. def __init__(self, identity, rate, remaining_time):
  5. error = "Bucket for {identity} with Rate {rate} is already full".format(
  6. identity = identity, rate = rate)
  7. self.meta_info = {
  8. "error": error,
  9. "identity": identity,
  10. "rate": str(rate),
  11. "remaining_time": remaining_time,
  12. }
  13. super(BucketFullException, self).__init__(error)
  14. class InvalidParams(Exception):
  15. def __init__(self, param_name):
  16. self.message = "Parameters missing or invalid:{param_name}".format(param_name = param_name)
  17. super(InvalidParams, self).__init__(self.message)
  18. class ImmutableClassProperty(Exception):
  19. def __init__(self, class_instance, prop):
  20. """Mutating class property is forbidden"""
  21. self.message = "{class_instance}.{prop} must not be mutated".format(
  22. class_instance = class_instance, prop = prop)
  23. super(ImmutableClassProperty, self).__init__(self.message)