Zend\Stratigility\Exception\MiddlewareException::fromErrorValue PHP Method

fromErrorValue() public static method

Create an instance based on an error value.
public static fromErrorValue ( mixed $err ) : self
$err mixed
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));
    }

Usage Example

Example #1
0
 /**
  * @param mixed $err
  * @throws Throwable|\Exception
  */
 private function raiseThrowableFromError($err)
 {
     if ($err instanceof Throwable || $err instanceof \Exception) {
         throw $err;
     }
     $this->triggerErrorDeprecation();
     throw Exception\MiddlewareException::fromErrorValue($err);
 }
MiddlewareException