2026-01-02 13:41:09 +00:00
|
|
|
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2016-06-30 08:24:03 +00:00
|
|
|
module Exceptions
|
|
|
|
|
|
|
|
|
|
class NotAuthorized < StandardError; end
|
2020-11-24 16:20:57 +00:00
|
|
|
|
2026-02-17 11:54:08 +00:00
|
|
|
class InvalidCSRFToken < NotAuthorized
|
|
|
|
|
def initialize
|
|
|
|
|
super(__('CSRF token verification failed.'))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-02-04 08:28:41 +00:00
|
|
|
class Forbidden < StandardError; end
|
|
|
|
|
|
2026-04-22 15:23:21 +00:00
|
|
|
class UnprocessableContent < StandardError
|
|
|
|
|
attr_reader :content
|
2025-05-14 16:55:17 +00:00
|
|
|
|
2026-04-22 15:23:21 +00:00
|
|
|
def initialize(message, content = nil)
|
2025-05-14 16:55:17 +00:00
|
|
|
super(message)
|
2026-04-22 15:23:21 +00:00
|
|
|
@content = content
|
2025-05-14 16:55:17 +00:00
|
|
|
end
|
|
|
|
|
end
|
2016-06-30 08:24:03 +00:00
|
|
|
|
2024-01-17 16:30:31 +00:00
|
|
|
class InvalidAttribute < StandardError
|
|
|
|
|
attr_reader :attribute
|
|
|
|
|
|
|
|
|
|
def initialize(attribute, message)
|
|
|
|
|
super(message)
|
|
|
|
|
@attribute = attribute
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
class MissingAttribute < StandardError
|
|
|
|
|
attr_reader :attribute
|
|
|
|
|
|
|
|
|
|
def initialize(attribute, message)
|
|
|
|
|
super(message)
|
|
|
|
|
@attribute = attribute
|
|
|
|
|
end
|
|
|
|
|
end
|
2024-01-16 11:06:18 +00:00
|
|
|
|
2026-04-22 15:23:21 +00:00
|
|
|
class ApplicationModel < UnprocessableContent
|
2021-12-13 06:59:20 +00:00
|
|
|
attr_reader :record
|
|
|
|
|
|
|
|
|
|
def initialize(record, message)
|
|
|
|
|
super(message)
|
|
|
|
|
@record = record
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-07-23 13:07:16 +00:00
|
|
|
def self.policy_class
|
|
|
|
|
ExceptionsPolicy
|
|
|
|
|
end
|
|
|
|
|
|
2016-06-30 08:24:03 +00:00
|
|
|
end
|