2022-12-29 07:26:40 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-08-14 18:04:58 +02:00
|
|
|
module Errors
|
|
|
|
class Base < StandardError
|
2021-08-19 17:50:24 +02:00
|
|
|
def status
|
|
|
|
500
|
|
|
|
end
|
|
|
|
|
|
|
|
def code
|
2022-12-29 07:26:40 +01:00
|
|
|
@code ||= self.class.name.sub("Errors::", "").underscore
|
2021-08-19 17:50:24 +02:00
|
|
|
end
|
2022-01-03 00:31:55 +01:00
|
|
|
|
2022-06-13 11:48:49 +02:00
|
|
|
def locale_code
|
|
|
|
code
|
|
|
|
end
|
|
|
|
|
2022-01-03 00:31:55 +01:00
|
|
|
def locale_tag
|
2022-06-13 11:48:49 +02:00
|
|
|
@locale_tag ||= "errors.#{locale_code}"
|
2022-01-03 00:31:55 +01:00
|
|
|
end
|
2021-08-19 17:50:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
class BadRequest < Base
|
|
|
|
def status
|
|
|
|
400
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class InvalidBanDuration < BadRequest
|
2021-08-14 18:04:58 +02:00
|
|
|
end
|
|
|
|
|
2023-01-08 14:03:54 +01:00
|
|
|
class QuestionTooLong < BadRequest
|
|
|
|
end
|
|
|
|
|
2021-08-19 17:50:24 +02:00
|
|
|
class Forbidden < Base
|
|
|
|
def status
|
|
|
|
403
|
|
|
|
end
|
2021-08-14 18:04:58 +02:00
|
|
|
end
|
2022-01-03 00:31:55 +01:00
|
|
|
|
|
|
|
class SelfAction < Forbidden
|
|
|
|
end
|
|
|
|
|
2022-11-06 15:01:01 +01:00
|
|
|
class InboxLocked < Forbidden
|
|
|
|
end
|
|
|
|
|
2022-01-03 00:31:55 +01:00
|
|
|
class FollowingSelf < SelfAction
|
|
|
|
end
|
|
|
|
|
|
|
|
class NotFound < Base
|
|
|
|
def status
|
|
|
|
404
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-11-13 14:38:11 +01:00
|
|
|
class NotAuthorized < Base
|
|
|
|
def status
|
|
|
|
401
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-03 00:31:55 +01:00
|
|
|
class UserNotFound < NotFound
|
|
|
|
end
|
2022-04-18 21:24:15 +02:00
|
|
|
|
|
|
|
# region User Blocking
|
|
|
|
class Blocked < Forbidden
|
|
|
|
end
|
|
|
|
|
|
|
|
class OtherBlockedSelf < Blocked
|
|
|
|
end
|
|
|
|
|
|
|
|
class BlockingSelf < SelfAction
|
|
|
|
end
|
|
|
|
|
|
|
|
class AskingOtherBlockedSelf < OtherBlockedSelf
|
|
|
|
end
|
|
|
|
|
|
|
|
class FollowingOtherBlockedSelf < OtherBlockedSelf
|
|
|
|
end
|
|
|
|
|
|
|
|
class SelfBlockedOther < Blocked
|
|
|
|
end
|
|
|
|
|
|
|
|
class AskingSelfBlockedOther < SelfBlockedOther
|
|
|
|
end
|
|
|
|
|
|
|
|
class FollowingSelfBlockedOther < SelfBlockedOther
|
|
|
|
end
|
|
|
|
|
|
|
|
class AnsweringOtherBlockedSelf < OtherBlockedSelf
|
|
|
|
end
|
|
|
|
|
|
|
|
class AnsweringSelfBlockedOther < SelfBlockedOther
|
|
|
|
end
|
2022-06-09 19:44:58 +02:00
|
|
|
|
|
|
|
class CommentingSelfBlockedOther < SelfBlockedOther
|
|
|
|
end
|
|
|
|
|
|
|
|
class CommentingOtherBlockedSelf < OtherBlockedSelf
|
|
|
|
end
|
2022-06-09 19:49:24 +02:00
|
|
|
|
|
|
|
class ReactingSelfBlockedOther < SelfBlockedOther
|
2022-06-13 11:48:49 +02:00
|
|
|
def locale_code
|
|
|
|
"self_blocked_other"
|
|
|
|
end
|
2022-06-09 19:49:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
class ReactingOtherBlockedSelf < OtherBlockedSelf
|
2022-06-13 11:48:49 +02:00
|
|
|
def locale_code
|
|
|
|
"other_blocked_self"
|
|
|
|
end
|
2022-06-09 19:49:24 +02:00
|
|
|
end
|
2022-06-09 19:55:56 +02:00
|
|
|
|
|
|
|
class ListingSelfBlockedOther < SelfBlockedOther
|
2022-06-13 11:48:49 +02:00
|
|
|
def locale_code
|
|
|
|
"self_blocked_other"
|
|
|
|
end
|
2022-06-09 19:55:56 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
class ListingOtherBlockedSelf < OtherBlockedSelf
|
2022-06-13 11:48:49 +02:00
|
|
|
def locale_code
|
|
|
|
"other_blocked_self"
|
|
|
|
end
|
2022-06-09 19:55:56 +02:00
|
|
|
end
|
2022-04-18 21:24:15 +02:00
|
|
|
# endregion
|
2022-12-28 02:59:51 +01:00
|
|
|
|
|
|
|
class MutingSelf < SelfAction
|
|
|
|
end
|
2021-08-19 17:50:24 +02:00
|
|
|
end
|