Retrospring/lib/errors.rb

126 lines
1.9 KiB
Ruby
Raw Normal View History

2022-12-28 22:26:40 -08:00
# frozen_string_literal: true
2021-08-14 09:04:58 -07:00
module Errors
class Base < StandardError
def status
500
end
def code
2022-12-28 22:26:40 -08:00
@code ||= self.class.name.sub("Errors::", "").underscore
end
def locale_code
code
end
def locale_tag
@locale_tag ||= "errors.#{locale_code}"
end
end
class BadRequest < Base
def status
400
end
end
class InvalidBanDuration < BadRequest
2021-08-14 09:04:58 -07:00
end
class Forbidden < Base
def status
403
end
2021-08-14 09:04:58 -07:00
end
class SelfAction < Forbidden
end
class InboxLocked < Forbidden
end
class FollowingSelf < SelfAction
end
class NotFound < Base
def status
404
end
end
2022-11-13 05:38:11 -08:00
class NotAuthorized < Base
def status
401
end
end
class UserNotFound < NotFound
end
2022-04-18 12:24:15 -07: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
class CommentingSelfBlockedOther < SelfBlockedOther
end
class CommentingOtherBlockedSelf < OtherBlockedSelf
end
class ReactingSelfBlockedOther < SelfBlockedOther
def locale_code
"self_blocked_other"
end
end
class ReactingOtherBlockedSelf < OtherBlockedSelf
def locale_code
"other_blocked_self"
end
end
2022-06-09 10:55:56 -07:00
class ListingSelfBlockedOther < SelfBlockedOther
def locale_code
"self_blocked_other"
end
2022-06-09 10:55:56 -07:00
end
class ListingOtherBlockedSelf < OtherBlockedSelf
def locale_code
"other_blocked_self"
end
2022-06-09 10:55:56 -07:00
end
2022-04-18 12:24:15 -07:00
# endregion
2022-12-27 17:59:51 -08:00
class MutingSelf < SelfAction
end
end