Throw Exception if there is no addresses file

Fixes #14
This commit is contained in:
Oliver Davies 2019-04-01 13:19:01 +01:00
parent db97fb8d60
commit fbe1edf8f0
3 changed files with 18 additions and 3 deletions

View file

@ -2,6 +2,7 @@
namespace Opdavies\GmailFilterBuilder\Service;
use Opdavies\GmailFilterBuilder\Exception\PartialNotFoundException;
use Tightenco\Collect\Support\Collection;
/**
@ -26,11 +27,13 @@ class Addresses
return file_exists($file);
});
if ($file) {
return include $file;
if (!$file) {
throw new PartialNotFoundException(vsprintf('%s does not exist.', [
$filename,
]));
}
return [];
return include $file;
}
/**