Skip to content

Commit

Permalink
add custom file not found exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mszulik committed Mar 7, 2022
1 parent c085836 commit 8769d67
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/Commands/ImportDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace Cybex\Protector\Commands;

use Cybex\Protector\Exceptions\FileNotFoundException;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\File;
use League\Flysystem\FileNotFoundException;
use LogicException;

/**
Expand Down
20 changes: 20 additions & 0 deletions src/Exceptions/FileNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Cybex\Protector\Exceptions;

use Exception;

/**
* Class FileNotFoundException
*
* Thrown if a file could not be found.
*
* @package Cybex\Protector\Exceptions
*/
class FileNotFoundException extends Exception
{
public function __construct(string $path)
{
parent::__construct(sprintf('The file "%s" was not found.', $path));
}
}
5 changes: 2 additions & 3 deletions src/Protector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
use Cybex\Protector\Exceptions\FailedCreatingDestinationPathException;
use Cybex\Protector\Exceptions\FailedDumpGenerationException;
use Cybex\Protector\Exceptions\FailedRemoteDatabaseFetchingException;
use Cybex\Protector\Exceptions\FileNotFoundException;
use Cybex\Protector\Exceptions\InvalidConfigurationException;
use Cybex\Protector\Exceptions\InvalidConnectionException;
use Cybex\Protector\Exceptions\InvalidEnvironmentException;
use Exception;
use GuzzleHttp\Psr7\StreamWrapper;
use Illuminate\Config\Repository;
use Illuminate\Foundation\Auth\User as AuthUser;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Artisan;
use League\Flysystem\FileNotFoundException;
use Psr\Http\Message\StreamInterface;
use Storage;
use Symfony\Component\Console\Output\BufferedOutput;
Expand Down Expand Up @@ -693,6 +691,7 @@ public function setServerUrl(string $serverUrl): void
* Returns the name of the most recent dump.
*
* @return string
* @throws FileNotFoundException
*/
public function getLatestDumpName(): string
{
Expand Down

0 comments on commit 8769d67

Please sign in to comment.