mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:54:05 +00:00
Fix #25 better error handling
This commit is contained in:
parent
fa5334f83e
commit
d2ec7f171d
2 changed files with 15 additions and 2 deletions
|
|
@ -149,7 +149,13 @@ class TenantManager
|
|||
{
|
||||
$domain = $domain ? : $this->currentDomain();
|
||||
|
||||
return $this->find($this->getIdByDomain($domain), $fields);
|
||||
$uuid = $this->getIdByDomain($domain);
|
||||
|
||||
if (is_null($uuid)) {
|
||||
throw new \Exception("Tenant with domain $domain could not be identified.");
|
||||
}
|
||||
|
||||
return $this->find($uuid, $fields);
|
||||
}
|
||||
|
||||
public static function currentDomain(): ?string
|
||||
|
|
|
|||
|
|
@ -91,4 +91,11 @@ class TenantManagerTest extends TestCase
|
|||
|
||||
$this->assertSame($domain, tenant()->create($domain)['domain']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function find_by_domain_throws_an_exception_when_an_unused_domain_is_supplied()
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
tenancy()->findByDomain('nonexistent.domain');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue