public function decorateException($error)
    {
        $application = $this->application;

        if (is_callable($error)) {
            $error = $application->getContainer()->call($error, [$application]);
        }

        if (is_object($error) && !($error instanceof \Exception)) {
            $error = method_exists($error,
                '__toString') ? $error->__toString() : 'Error with object ' . get_class($error);
        }

        if (is_resource($error)) {
            $error = 'Error with resource type ' . get_resource_type($error);
        }

        if (is_array($error)) {
            $error = implode("\n", $error);
        }

        if (!($error instanceof \Exception)) {
            $error = new \Exception(is_scalar($error) ? $error : 'Error with ' . gettype($error));
        }

        return $error;
    }
public function decorateException($error)
    {
        $application = $this->application;

        if (is_callable($error)) {
            $error = $application->getContainer()->call($error, [$application]);
        }

        if (is_object($error) && !($error instanceof \Exception)) {
            $error = method_exists($error,
                '__toString') ? $error->__toString() : 'Error with object ' . get_class($error);
        }

        if (is_resource($error)) {
            $error = 'Error with resource type ' . get_resource_type($error);
        }

        if (is_array($error)) {
            $error = implode("\n", $error);
        }

        if (!($error instanceof \Exception)) {
            $error = new \Exception(is_scalar($error) ? $error : 'Error with ' . gettype($error));
        }

        return $error;
    }
public function decorateException ( $ error ) { $ application = $ this -> application ; if ( is_callable ( $ error ) ) { $ error = $ application -> getContainer ( ) -> call ( $ error , [ $ application ] ) ; } if ( is_object ( $ error ) && ! ( $ error instanceof \ Exception ) ) { $ error = method_exists ( $ error , '__toString' ) ? $ error -> __toString ( ) : 'Error with object ' . get_class ( $ error ) ; } if ( is_resource ( $ error ) ) { $ error = 'Error with resource type ' . get_resource_type ( $ error ) ; } if ( is_array ( $ error ) ) { $ error = implode ( "\n" , $ error ) ; } if ( ! ( $ error instanceof \ Exception ) ) { $ error = new \ Exception ( is_scalar ( $ error ) ? $ error : 'Error with ' . gettype ( $ error ) ) ; } return $ error ; }
Convert any type into an exception

@param $error
@return \Exception|string
Convert any type into an exception