mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 13:54:03 +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,19 +77,22 @@ class Tenancy
|
||||||
public function run(Tenant $tenant, Closure $callback): mixed
|
public function run(Tenant $tenant, Closure $callback): mixed
|
||||||
{
|
{
|
||||||
$originalTenant = $this->tenant;
|
$originalTenant = $this->tenant;
|
||||||
|
$result = null;
|
||||||
|
|
||||||
|
try {
|
||||||
$this->initialize($tenant);
|
$this->initialize($tenant);
|
||||||
$result = $callback($tenant);
|
$result = $callback($tenant);
|
||||||
|
} finally {
|
||||||
if ($result instanceof PendingDispatch) { // #1277
|
|
||||||
$result = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($originalTenant) {
|
if ($originalTenant) {
|
||||||
$this->initialize($originalTenant);
|
$this->initialize($originalTenant);
|
||||||
} else {
|
} else {
|
||||||
$this->end();
|
$this->end();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result instanceof PendingDispatch) { // #1277
|
||||||
|
$result = null;
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue