hensei-api/app/errors/party_share_errors.rb
Justin Edmund 5597cab95c
Party sharing into crews (#207)
* add party_shares table and model with associations

* add party share errors and blueprint

* add party shares controller and routes

* include shared parties in listings and show

* add party share factory and model specs

* add party shares controller specs

* include shares in party response for owners

* add crew shared_parties endpoint
2026-01-05 02:39:32 -08:00

77 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module PartyShareErrors
# Base class for all party share-related errors
class PartyShareError < StandardError
def http_status
:unprocessable_entity
end
def code
self.class.name.demodulize.underscore
end
def to_hash
{
message: message,
code: code
}
end
end
class NotInCrewError < PartyShareError
def http_status
:unprocessable_entity
end
def code
'not_in_crew'
end
def message
'You must be in a crew to share parties'
end
end
class NotPartyOwnerError < PartyShareError
def http_status
:forbidden
end
def code
'not_party_owner'
end
def message
'Only the party owner can share this party'
end
end
class AlreadySharedError < PartyShareError
def http_status
:conflict
end
def code
'already_shared'
end
def message
'This party is already shared with this crew'
end
end
class CanOnlyShareToOwnCrewError < PartyShareError
def http_status
:forbidden
end
def code
'can_only_share_to_own_crew'
end
def message
'You can only share parties with your own crew'
end
end
end