-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #517 from NiR-/1.x-fs-exceptions
Introduce StorageFailure and FileNotFound exceptions
- Loading branch information
Showing
9 changed files
with
194 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Gaufrette\Exception; | ||
|
||
use Gaufrette\Exception; | ||
|
||
/** | ||
* Exception thrown when an unexpected error happened at the storage level (or its underlying sdk). | ||
* | ||
* @author Albin Kerouanton <[email protected]> | ||
*/ | ||
class StorageFailure extends \RuntimeException implements Exception | ||
{ | ||
/** | ||
* Instantiate a new StorageFailure exception for a particular adapter action. | ||
* | ||
* @param string $action The adapter action (e.g read, write, listKeys, ...) that throw the exception. | ||
* @param array $args Arguments used by the action (like the read key). | ||
* @param \Exception|null $previous Previous exception, if any was thrown (like exception from AWS sdk). | ||
* | ||
* @return StorageFailure | ||
*/ | ||
public static function unexpectedFailure($action, array $args, \Exception $previous = null) | ||
{ | ||
$args = array_map(function ($k, $v) { | ||
$v = is_string($v) ? '"'.$v.'"' : $v; | ||
|
||
return "{$k}: {$v}"; | ||
}, array_keys($args), $args); | ||
|
||
return new self( | ||
sprintf('An unexpected error happened during %s (%s).', $action, implode(', ', $args)), | ||
0, | ||
$previous | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.