Všetky výnimky sú v RoundlyConsulting\Teams\Exceptions a rozširujú TeamsException, ktorá rozširuje RuntimeException. Zachyťte základný typ pre akúkoľvek chybu balíka, alebo konkrétny pre cielenú obsluhu:
| Výnimka | Vyhadzuje | Kedy |
|---|---|---|
InviteExpiredException | AcceptInviteAction | Platnosť pozvánky (expires_at) vypršala. |
InviteExhaustedException | AcceptInviteAction | uses dosiahlo max_uses — aj pri už spotrebovanej jednorazovej pozvánke. |
InviteEmailMismatchException | AcceptInviteAction | Pozvánka na konkrétny e-mail dostane iný alebo žiadny e-mail (bez ohľadu na veľkosť písmen). |
InviteNotFoundException | Teams::invites()->accept() | Kódu nezodpovedá žiadna pozvánka, pozvánka bola zrušená alebo jej tím zmazaný. |
InviteNotFoundException | for($t)->invites()->resend() / revoke() | Pozvánka patrí inému tímu. |
JoinRequestNotFoundException | for($t)->joinRequests()->approve() / deny() | Žiadosť patrí inému tímu. |
JoinRequestNotPendingException | for($t)->joinRequests()->approve() / deny() | Žiadosť už bola schválená, zamietnutá alebo vypršala — aj keď ju súčasne vybavil niekto iný. |
MemberNotFoundException | for($t)->members()->changeRole() | Model nie je členom tímu. |
MemberNotFoundException | for($t)->members()->grant($m)->assignRole() … | Pridanie pre model bez členstva v tíme alebo s vypršaným členstvom. |
TeamContextException | ScopedToTeam, UniqueInTeam, switchTo(), setCurrentMany(), teams.context | Chýba kontext, viac tímov bez určenia, riadok mimo kontextu, používateľ, ktorý nie je aktívnym členom, chýbajúci používateľ na overenie, neuložený tím, routa bez parametra tímu — alebo pri štarte jobu vo fronte člen, ktorý po odoslaní stratil prístup. |
TeamHierarchyException | uloženie tímu s rodičom | Vnáranie je vypnuté, rodič je samotný tím alebo jeho potomok, alebo presun ide hlbšie ako nesting.max_depth. |
TeamsException | joinRequests()->open(), members()->add(), transferOwnershipTo(), scopedKey(), members()->grant() | Základná trieda. Priamo ju vyhodí žiadosť do tímu len na pozvánky, žiadosť od aktívneho člena, dosiahnutý limit miest, startsAt pri vypnutých dátumoch začiatku, začiatok, ktorý nie je pred expiráciou, nebezpečná prípona scopedKey() a grant() pri vypnutom moste k permissions. |
use RoundlyConsulting\Teams\Exceptions\InviteEmailMismatchException;
use RoundlyConsulting\Teams\Exceptions\InviteExhaustedException;
use RoundlyConsulting\Teams\Exceptions\InviteExpiredException;
use RoundlyConsulting\Teams\Exceptions\InviteNotFoundException;
use RoundlyConsulting\Teams\Exceptions\TeamsException;
try {
Teams::invites()->accept($code, $user, email: $user->email);
} catch (InviteExpiredException) {
// the link has expired
} catch (InviteExhaustedException) {
// no seats left, or a single-use link already consumed
} catch (InviteEmailMismatchException) {
// the wrong recipient
} catch (InviteNotFoundException) {
// an unknown code, a revoked invite or a deleted team
} catch (TeamsException $e) {
// any other teams error — e.g. a seat limit
}Kontroly pozvánky idú v poradí vypršaná → vyčerpaná → zrušená → nezhodný e-mail → zmazaný tím, takže zachytíte prvú podmienku, ktorá zlyhá.
Preložené hlášky
Hlášky výnimiek pozvánok, žiadostí, členstiev, limitu miest, kontextu tímu, vnárania, mosta k permissions a konfigurácie intervalov — aj validačná hláška UniqueInTeam — pochádzajú z prekladov balíka (menný priestor teams::) a riadia sa jazykom aplikácie; balík obsahuje angličtinu a slovenčinu:
| Kľúč | Predvolená anglická hláška |
|---|---|
teams::errors.already_member | The given model is already a member of team #:team. |
teams::errors.invite_expired | The invite ":code" has expired. |
teams::errors.invite_email_mismatch | This invite is addressed to ":email". |
teams::errors.invite_exhausted | The invite ":code" has reached its usage limit. |
teams::errors.invite_not_found | No invite was found for the code ":code". |
teams::errors.invite_team_missing | The team of invite #:id no longer exists. |
teams::errors.invite_unavailable | Invite #:id is no longer available. |
teams::errors.invite_not_in_team | Invite #:id does not belong to this team. |
teams::errors.join_request_not_pending | Join request #:id has already been resolved. |
teams::errors.join_request_not_in_team | Join request #:id does not belong to this team. |
teams::errors.member_not_found | The given model is not a member of team #:team. |
teams::errors.join_policy_forbids_requests | This team is invite-only and does not accept join requests. |
teams::errors.invalid_config_value | Configuration value [:key] must be :expected, [:given] given. |
teams::errors.config_expectations.positive_interval | a positive interval such as "7 days" |
teams::errors.config_expectations.non_negative_interval | a zero or positive interval such as "30 days" |
teams::errors.max_seats_reached | This team has reached its seat limit (:count seat).|This team has reached its seat limit (:count seats). |
teams::errors.context_missing | No team context is set. |
teams::errors.context_ambiguous | Several teams are in context: name the team explicitly. |
teams::errors.context_outside | Team #:team is outside the current team context. |
teams::errors.context_not_accessible | The user is not an active member of team #:team. |
teams::errors.context_no_user | Setting several teams needs a user to check memberships against. |
teams::errors.context_switch_no_user | Switching teams needs a user to check the membership against. |
teams::errors.context_revoked | The member who set the team context may no longer act in team #:team. |
teams::errors.context_actor_missing | The member who set the team context no longer exists. |
teams::errors.context_unsaved_team | A team must be saved before it can be the current team. |
teams::errors.context_route_parameter | The route has no [:parameter] parameter to read the team from. |
teams::errors.start_dates_disabled | Membership start dates are disabled: turn on teams.members.start_dates. |
teams::errors.membership_window | A membership must start before it expires. |
teams::errors.nesting_disabled | Nested teams are disabled. |
teams::errors.nesting_cycle | Team #:team cannot be placed under itself or one of its descendants. |
teams::errors.nesting_too_deep | {1} A team may sit at most :count level below its root team.|[0,*] A team may sit at most :count levels below its root team. |
teams::errors.unsafe_scoped_key | The scoped key ":suffix" may not contain "." or ".." segments. |
teams::errors.permissions_bridge_not_installed | teams.permissions.bridge is on, but roundly-consulting/permissions-for-laravel ^2.1 is not installed. |
teams::errors.permissions_bridge_assignments_off | teams.permissions.bridge needs scoped assignments: turn on permissions.assignments.enabled and run the permissions migrations. |
teams::errors.permissions_bridge_off | Member grants need the permissions bridge: turn on teams.permissions.bridge. |
teams::validation.unique_in_team | The :attribute has already been taken in this team. |
max_seats_reached sa vykresľuje cez trans_choice(): angličtina používa tvar singular|plural, slovenčina {0} …|{1} …|[2,4] …|[5,*] …. Prepísaný riadok môže zostať jediný, bez | — použije sa tak, ako je.
php artisan vendor:publish --tag="teams-translations"
# edit lang/vendor/teams/en/errors.php or lang/vendor/teams/sk/errors.php, or add other localesPrejavte lásku k open source
Tento balík je zadarmo pod licenciou MIT. Ak vám šetrí čas, jednorazový príspevok alebo členstvo na Patreone nám pomôže ho ďalej udržiavať, testovať a dokumentovať.
Ďalšie spôsoby podpory vrátane kryptomienOdoslaním daru súhlasíte s našimi podmienkami prijímania darov.
Chcete to zabudovať do svojho produktu?
Naše balíky integrujeme do zákazkových Laravel a AI riešení. Napíšte nám, na čom pracujete, a ozveme sa do 48 hodín.