exceptions.rb 799 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Exceptions
  3. class NotAuthorized < StandardError; end
  4. class Forbidden < StandardError; end
  5. class UnprocessableEntity < StandardError; end
  6. class InvalidAttribute < StandardError
  7. attr_reader :attribute
  8. def initialize(attribute, message)
  9. super(message)
  10. @attribute = attribute
  11. end
  12. end
  13. class MissingAttribute < StandardError
  14. attr_reader :attribute
  15. def initialize(attribute, message)
  16. super(message)
  17. @attribute = attribute
  18. end
  19. end
  20. class ApplicationModel < UnprocessableEntity
  21. attr_reader :record
  22. def initialize(record, message)
  23. super(message)
  24. @record = record
  25. end
  26. end
  27. def self.policy_class
  28. ExceptionsPolicy
  29. end
  30. end