1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 19:14:04 +00:00

[2.x] Add missing field in InitializeTenancy middleware (#135)

* Add missing field

* Make field protected

* Specify exact exception type

* Changed Closure on callable
This commit is contained in:
Anton Komarev 2019-09-26 18:01:38 +03:00 committed by Samuel Štancl
parent d00cf97e0e
commit 3f4018f93c

View file

@ -5,10 +5,14 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Middleware; namespace Stancl\Tenancy\Middleware;
use Closure; use Closure;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedException;
class InitializeTenancy class InitializeTenancy
{ {
public function __construct(Closure $onFail = null) /** @var callable */
protected $onFail;
public function __construct(callable $onFail = null)
{ {
$this->onFail = $onFail ?? function ($e) { $this->onFail = $onFail ?? function ($e) {
throw $e; throw $e;
@ -26,7 +30,7 @@ class InitializeTenancy
{ {
try { try {
tenancy()->init(); tenancy()->init();
} catch (\Exception $e) { } catch (TenantCouldNotBeIdentifiedException $e) {
($this->onFail)($e); ($this->onFail)($e);
} }