mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 09:34:04 +00:00
handle exceptions in Tenancy:run()
This commit is contained in:
parent
7bc2bb6f6a
commit
b9cc63feed
1 changed files with 11 additions and 8 deletions
|
|
@ -77,20 +77,23 @@ class Tenancy
|
|||
public function run(Tenant $tenant, Closure $callback): mixed
|
||||
{
|
||||
$originalTenant = $this->tenant;
|
||||
$result = null;
|
||||
|
||||
$this->initialize($tenant);
|
||||
$result = $callback($tenant);
|
||||
try {
|
||||
$this->initialize($tenant);
|
||||
$result = $callback($tenant);
|
||||
} finally {
|
||||
if ($originalTenant) {
|
||||
$this->initialize($originalTenant);
|
||||
} else {
|
||||
$this->end();
|
||||
}
|
||||
}
|
||||
|
||||
if ($result instanceof PendingDispatch) { // #1277
|
||||
$result = null;
|
||||
}
|
||||
|
||||
if ($originalTenant) {
|
||||
$this->initialize($originalTenant);
|
||||
} else {
|
||||
$this->end();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue