I using Zend Gdata library for search video Youtube API.
If I make a bad request, then a zend exception..
Example:
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' in D:\Webserver\domains\loc\controller\Zend\Gdata\App.php:710
Stack trace:
#0 D:\Webserver\domains\loc\controller\Zend\Gdata.php(221): Zend_Gdata_App->performHttpRequest('GET', 'http://gdata.yo...', Array, NULL, NULL, NULL)
#1 D:\Webserver\domains\loc\controller\Zend\Gdata\App.php(876): Zend_Gdata->performHttpRequest('GET', 'http://gdata.yo...', Array)
#2 D:\Webserver\domains\loc\controller\Zend\Gdata\App.php(764): Zend_Gdata_App->get('http://gdata.yo...', NULL)
#3 D:\Webserver\domains\loc\controller\Zend\Gdata\App.php(220): Zend_Gdata_App->importUrl('http://gdata.yo...', 'Zend_Gdata_YouT...', NULL)
#4 D:\Webserver\domains\loc\controller\Zend\Gdata.php(187): Zend_Gdata_App->getEntry('http://gdata.yo...', 'Zend_Gdata_YouT...')
#5 D:\Webserver\domains\loc\controller\Zend\Gdata\YouTube.php(293): Zend_Gdata->getEntry('http://gdata.yo...', 'Zend_Gdata_YouT...')
#6 D:\Webserver\domains\loc\controller\Yo in D:\Webserver\domains\loc\controller\Zend\Gdata\App.php on line 710
But I do not want users of my site have seen this error ... I need to catch this error and cause no Exception and just want to get the text of the error .. What should I do?
Put the code that causes the exception into a try/catch statement
try {
// code calling Zend_Gdata_App->performHttpRequest
} catch(Zend_Gdata_App_HttpException $e) {
$message = $e->getMessage();
// do something with $message now
}
More information: http://de3.php.net/manual/en/language.exceptions.php
Related
I've been using using Tidy just by enabling its extension in php.ini (in XAMPP, WINDOWS OS)
I'm trying to do the same on XAMPP,macOS by enabling the Tidy extendion in the php.ini which is located in /Applications/XAMPP/xamppfiles/etc/php.ini but I still get php error when i try to instantiate the tidy class:
Fatal error: Uncaught Error: Class "tidy" not found in /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/functions.php:48 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/models/user.php(402): truncate('James is a powe...', 200) #1 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/temp/us.php(237): User->truncate('James is a powe...', 200) #2 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/temp/us.php(283): Page->sectionIntro(Object(stdClass)) #3 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/temp/us.php(34): Page->LayoutBottomAream(Object(stdClass)) #4 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/temp/us.php(355): Page->__construct(Array) #5 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/controller.php(11): include('/Applications/X...') #6 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/us.php(5): Controller->view('joacmedia/temp/...', Array) #7 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/controller.php(11): include('/Applications/X...') #8 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/controllers/us.php(47): Controller->view('joacmedia/us', Array) #9 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/app.php(61): Us->index('jay') #10 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/index.php(6): App->__construct() #11 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/functions.php on line 48
what should i do to get this error fixed ?
`
//add ellipsis to string
function truncate($html,$length){
$tidy = new tidy();
if ((int)mb_strlen($html,'UTF-8') >= (int)$length ) {
$ellipsis = "<div class='ellipsis_show'>
<div data-href='false' class='text-right see_more_text text-secondary'><strong>...</strong>see more</div>
</div>";
return trim((strip_empty_tag(convert_ENCODE($tidy->repairString("<span data-show-summary='true'>".(NewLineToBreak(substr(trim($html),0,$length)))."</span>"."<span class='text_exposed_hide hide visually_hidden'>".trim(NewLineToBreak(substr($html,$length)))."</span>"),'UTF-8')))).$ellipsis;
}
return trim((strip_empty_tag(convert_ENCODE(tidy_repair_string(NewLineToBreak($html)),'UTF-8'))));
}
`
You are doing a new tidy() in your function and I suspect you do not have the tiny class defined in the same file or namespace. If you use namespaces you shoud do the use your/namespace/to/tiny or you should do a require/include in your functions.php file to include the desired tiny class file.
when accessing the www.hostname/phpmyadmin/ page i get the blank page. Tried to reinstall PHP,HTTPD and MYSQL.
After running php index.php in the phpmyadmin folder I get the following error:
[root#ansible1 phpmyadmin]# php index.php
PHP Fatal error: Uncaught Error: Call to a member function getCookie() on null in /usr/share/phpmyadmin/libraries/classes/Url.php:219
Stack trace:
#0 /usr/share/phpmyadmin/libraries/classes/Url.php(171): PhpMyAdmin\Url::getCommonRaw(Array, '?')
#1 /usr/share/phpmyadmin/libraries/classes/Core.php(762): PhpMyAdmin\Url::getCommon(Array)
#2 /usr/share/phpmyadmin/libraries/classes/Core.php(338): PhpMyAdmin\Core::linkURL('https://secure....')
#3 /usr/share/phpmyadmin/libraries/classes/Core.php(364): PhpMyAdmin\Core::getPHPDocLink('book.json.php')
#4 /usr/share/phpmyadmin/libraries/classes/Core.php(1006): PhpMyAdmin\Core::warnMissingExtension('json', true)
#5 /usr/share/phpmyadmin/libraries/common.inc.php(110): PhpMyAdmin\Core::checkExtensions()
#6 /usr/share/phpmyadmin/index.php(23): require_once('/usr/share/phpm...')
#7 {main}
thrown in /usr/share/phpmyadmin/libraries/classes/Url.php on line 219
On the line 219 in the corresponding file:
public static function getCommonRaw($params = [], $divider = '?')
{
/** #var Config $PMA_Config */
global $PMA_Config;
$separator = Url::getArgSeparator();
// avoid overwriting when creating navi panel links to servers
if (isset($GLOBALS['server'])
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']
&& ! isset($params['server'])
&& ! $PMA_Config->get('is_setup')
) {
$params['server'] = $GLOBALS['server'];
}
if (empty($PMA_Config->getCookie('pma_lang')) && ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
$query = http_build_query($params, '', $separator);
if ($divider != '?' || strlen($query) > 0) {
return $divider . $query;
}
Not sure what I am doing wrong but havent found this error on the internet....
The blowfish secret is set:
$cfg['blowfish_secret'] = 'H2OxcGXxflSd8JwrwVlh6KW6s2rER63i';
Any idea what could I be missing? Even a hint what direction to look will be appreciated.
EDIT1:
Downgraded to version 4.9.4 - getting the similar error:
So after downgrading to version 4.9.4 I get the very similar....
[root#ansible1 phpmyadmin]# php index.php
PHP Fatal error: Uncaught Error: Call to a member function getCookie() on null in /usr/share/phpmyadmin/libraries/classes/Url.php:217
Stack trace:
#0 /usr/share/phpmyadmin/libraries/classes/Url.php(169): PhpMyAdmin\Url::getCommonRaw(Array, '?')
#1 /usr/share/phpmyadmin/libraries/classes/Core.php(749): PhpMyAdmin\Url::getCommon(Array)
#2 /usr/share/phpmyadmin/libraries/classes/Core.php(330): PhpMyAdmin\Core::linkURL('https://secure....')
#3 /usr/share/phpmyadmin/libraries/classes/Core.php(353): PhpMyAdmin\Core::getPHPDocLink('book.json.php')
#4 /usr/share/phpmyadmin/libraries/classes/Core.php(987): PhpMyAdmin\Core::warnMissingExtension('json', true)
#5 /usr/share/phpmyadmin/libraries/common.inc.php(106): PhpMyAdmin\Core::checkExtensions()
#6 /usr/share/phpmyadmin/index.php(27): require_once('/usr/share/phpm...')
#7 {main}
thrown in /usr/share/phpmyadmin/libraries/classes/Url.php on line 217
The page now shows: Access Denied - simply written, no pictures or anything.
What am I missing? :/
[Browser view1
I don't know if my previous post is visible, so I post it again:
I had the same error message, and row #4 says: "PhpMyAdmin\Core::warnMissingExtension('json', true)".
After installing php-json package, problem was solved for me.
I wrote service to sending emails in ZF2 and unfortunatelly sometimes I get exception:
Zend\Mail\Protocol\Exception\RuntimeException
Could not read from [smtp server]
Part of stack trace:
#0 /homez.157/pastydol/www/vendor/zendframework/zendframework/library/Zend/Mail/Protocol/AbstractProtocol.php(339): Zend\Mail\Protocol\AbstractProtocol->_receive(300)
#1 /homez.157/pastydol/www/vendor/zendframework/zendframework/library/Zend/Mail/Protocol/Smtp.php(353): Zend\Mail\Protocol\AbstractProtocol->_expect(221, 300)
#2 /homez.157/pastydol/www/vendor/zendframework/zendframework/library/Zend/Mail/Protocol/Smtp.php(389): Zend\Mail\Protocol\Smtp->quit()
#3 /homez.157/pastydol/www/vendor/zendframework/zendframework/library/Zend/Mail/Protocol/Smtp.php(380): Zend\Mail\Protocol\Smtp->_disconnect()
#4 /homez.157/pastydol/www/vendor/zendframework/zendframework/library/Zend/Mail/Transport/Smtp.php(152): Zend\Mail\Protocol\Smtp->disconnect()
#5 /homez.157/pastydol/www/module/Page/src/Page/Controller/OrderController.php(144): Zend\Mail\Transport\Smtp->__destruct()
I want to catch this exception, in service, which sending email I did:
try {
$transport->send($mail);
} catch(\Zend\Mail\Exception $e) {
return -1;
}
catch(\Exception $ex) {
return -1;
}
But it doesn't work, I still getting these exceptions.
I have the following PHP code:
try{
$doc = couchDocument::getInstance($db,"document10");
}catch(couchExpention $e){
echo $e->getMessage();
}
However instead of the desired output I get:
PHP Fatal error: Uncaught exception 'couchNotFoundException' with message 'Object Not Found - missing (GET /db/document10[])' in /var/www/public_html/lib/couchClient.php:1012
Stack trace:
#0 /var/www/public_html/lib/couchClient.php(157): couchException::factory(Array, 'GET', '/db/169488e77e2...', Array)
#1 /var/www/public_html/lib/couchClient.php(427): couchClient->_queryAndTest('GET', '/db/169488e77e2...', Array, Array)
#2 /var/www/public_html/lib/couchDocument.php(47): couchClient->getDoc('169488e77e2j385...')
#3 /var/www/public_html/lib/couchDocument.php(102): couchDocument->load('169488e77e2j385...')
#4 /var/www/public_html/index.php(8): couchDocument::getInstance(Object(couchClient), '169488e77e2j385...')
#5 {main}
thrown in /var/www/public_html/lib/couchClient.php on line 1012
You code is trying to catch a couchExpention instead of a couchException
I need to verify the existence of a method in a controller from a model with codeigniter 2.0.2. and HMVC.
I'm trying to do with ReflectionClass:hasMethod(), without success.
My code in Model:
function hasPanel($controller){
$rc = new ReflectionClass($controller);
if($rc::hasMethod("panel_base")){
return true;
}
return false;
}
And the unwelcome error:
Fatal error: Uncaught exception 'ReflectionException' with message 'Class administracion does not exist' in D:\xampp\htdocs\sea\application\models\auth\permisos.php:368
Stack trace:
#0 D:\xampp\htdocs\sea\application\models\auth\permisos.php(368): ReflectionClass->__construct('administracion')
#1 D:\xampp\htdocs\sea\application\models\auth\permisos.php(357): Permisos->hasPanel('administracion')
#2 D:\xampp\htdocs\sea\application\controllers\auth\identificar.php(101): Permisos->getControladores('administracion')
#3 [internal function]: Identificar->modulo()
#4 D:\xampp\htdocs\sea\application\core\Admin_controller.php(317): call_user_func_array(Array, Array)
#5 D:\xampp\htdocs\sea\system\core\CodeIgniter.php(305): Admin_controller->_remap('modulo', Array)
#6 D:\xampp\htdocs\sea\www\index.php(252): require_once('D:\xampp\htdocs...')
#7 {main}
thrown in D:\xampp\htdocs\sea\application\models\auth\permisos.php on line 368
EDITED
This solves the above...
function hasPanel($controller,$route){
include_once($route);
$rc = new ReflectionClass($controller);
if($rc::hasMethod("panel_base")){
return true;
}
return false;
}
But causes this:
Fatal error: Non-static method ReflectionClass::hasMethod() cannot be called statically, assuming $this from incompatible context in D:\xampp\htdocs\sea\application\models\auth\permisos.php on line 373
Some idea?
I'm not entirely sure, but this might be as simple as $rc->hasMethod("panel_base"); You did instantiate a new class. . .
Change
$rc::hasMethod("panel_base")
to
$rc->hasMethod("panel_base")