This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/error-handling-v2' into dev-2.0.0
Close #79
- Loading branch information
Showing
8 changed files
with
137 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/zendframework/zend-stratigility for the canonical source repository | ||
* @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Stratigility\Exception; | ||
|
||
use RuntimeException; | ||
|
||
/** | ||
* Exception raised when a string $err is provided and raise throwables is enabled. | ||
* | ||
* @todo Remove for 2.0.0. | ||
*/ | ||
class MiddlewareException extends RuntimeException | ||
{ | ||
/** | ||
* Create an instance based on an error value. | ||
* | ||
* @param mixed $err | ||
* @return self | ||
*/ | ||
public static function fromErrorValue($err) | ||
{ | ||
if (is_object($err)) { | ||
return self::fromType(get_class($err)); | ||
} | ||
|
||
if (is_array($err)) { | ||
return self::fromType(gettype($err)); | ||
} | ||
|
||
if (is_string($err)) { | ||
throw new self($err); | ||
} | ||
|
||
return self::fromType(var_export($err, true)); | ||
} | ||
|
||
/** | ||
* Create an instance using a templated error string. | ||
* | ||
* @param string $value | ||
* @return self | ||
*/ | ||
private static function fromType($value) | ||
{ | ||
return new self(sprintf( | ||
'Middleware raised an error condition: %s', | ||
$value | ||
)); | ||
} | ||
} |
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