草庐IT

catch-exception

全部标签

php - <b> fatal error </b> : Uncaught exception 'Exception' with message 'Failed to connect to api.twitter.com port 443: Connection timed out'

我正在开发一个Codeigniter项目,在该项目中我使用twitterapi库来获取twitter数据。在我更改服务器之前它工作得很好,但是在更改服务器之后它产生了以下错误。我不知道问题所在。Fatalerror:Uncaughtexception'Exception'withmessage'Failedtoconnecttoapi.twitter.comport443:Connectiontimedout'in/my/project/path/myProject/application/ws/libraries/TwitterAPIExchange.php:297Stacktrac

php - 在 Magento 中,如何读取 exception.log?

我找不到任何关于如何在Magento中读取exception.log的文档;有关如何阅读此内容的文档在哪里?如果没有文档,异常打印的顺序是什么?#0是最后发生还是最先发生?Stacktrace:#0.../html/lib/Varien/Db/Statement/Pdo/Mysql.php(110):Zend_Db_Statement_Pdo->_execute(Array)#1.../html/lib/Zend/Db/Statement.php(300):Varien_Db_Statement_Pdo_Mysql->_execute(Array)#2.../html/lib/Zend

php - symfony2 phpunit : how to get exception message when status code is not expected one

在我的symfony2应用程序中,我使用phpunit来测试每个Controller的Action响应的状态代码是否是预期的。如果不是,我如何让phpunit显示异常附带的错误消息,或者最好模拟一个探查器异常页面?这是因为我在phpunit中有一个返回500代码的操作,但它在我的浏览器中加载得很好。我的代码:/***@dataProviderurlProvider*@param$url*/publicfunctiontestPageIsSuccessful($url){$client=self::createClient(array(),array('PHP_AUTH_USER'=>'

php - session : Fatal error: Exception thrown without a stack frame in Unknown on line 0 中的对象

session_start();$_SESSION['dbo']=NEWPDO('sqlite:database.db3');给出:fatalerror:在第0行的Unknown中抛出没有堆栈帧的异常但是将它放入普通变量不会出错。我所要做的就是将对象放入session中,以便它被初始化一次。 最佳答案 某些对象无法序列化并存储在$_SESSION中。如果您的意图是在session中存储数据库连接以供重用,请不要遵循该promise:它不起作用。来自PHPreferenceonserialize:[...]serialize()han

php - Symfony2 - Doctrine2 : Cross-Database Join Column throws Mapping-Exception

您好,想在两个实体之间进行连接。实体在不同的数据库中:这是我设置数据库配置的方式:doctrine:dbal:default_connection:defaultconnections:default:driver:%database_driver%host:%database_host%port:%database_port%dbname:%database_name%user:%database_user%password:%database_password%charset:UTF8mapping_types:enum:stringdata_warehouse:driver:%d

php - 在 PHP : An exception has been raised as a result of client data 中调试 SOAP 调用

我正在使用UPSAPI,但在调试时遇到困难。我得到以下堆栈跟踪:DetailsType:SoapFaultMessage:Anexceptionhasbeenraisedasaresultofclientdata.File:/Users/shawn/Documents/work/sites/Wingspan/kaleco/lib/SixString/Utilities/Ups.phpLine:161Trace#0/Users/shawn/Documents/work/sites/Wingspan/kaleco/lib/SixString/Utilities/Ups.php(161):S

php - Laravel 查询生成器 : Select all fields except for a few

使用Laravel查询构建器,可以很容易地使用->select()选择或别名字段。如何选择除少数字段以外的所有字段?例如,我不希望将记录的id返回给前端。 最佳答案 http://laravel.com/docs/4.2/eloquent如果您仍然不介意从技术上选择它们,您可以抑制来自Laravel的默认数组/JSON转换的字段:classUserextendsEloquent{protected$hidden=['password','id',...];} 关于php-Laravel查

php - Codeception 测试失败,即使 try-catch

我是PHP和Codeception的新手,我一直在尝试使用页面对象编写一些基本测试。这是我的页面类中的一个函数示例。理想情况下,它应该单击一个按钮,如果没有按钮,则只记录一条评论。try{$I->click(self::$buttonAddNewAddress);}catch(Expection$e){$I->comment('Thisaddresswillbethefirstone');}我得到«未找到带有'//div[@class="buttons-set"]/button'的失败链接或按钮或CSS或XPath元素。»每次我尝试运行此代码时。在AcceptanceTester.ph

php - 代码点火器 3 : Can't catch database error using try catch block

我正在开发一个api,它处理来自客户端的请求,然后从服务器获取响应(使用codeigniter3开发)并将其转发回客户端。但是,如果出现任何数据库错误,例如重复ID或空值,模型类将无法处理该错误以显示正确的错误消息。我试过trycatchblock但还没有成功。这是模型:publicfunctionadd(){try{$this->db->trans_start(FALSE);$this->db->insert('users',$preparedData);$this->db->trans_complete();if($this->db->trans_status()===FALSE)

php - 为什么 Yii2 因 try/catch 而崩溃?

我插入一个条目,其中有一个主键的副本。publicfunctionactionInc(){$add=newCountry();$add->code='QI';$add->name='Qiang';$add->population='4444444';try{$add->save();return$this->render('inc',['count'=>'Ok',]);}catch(Exception$exception){return$this->render('inc',['count'=>'Error',]);}}但是我需要那个应用程序不宕机,继续工作,但是就是不行...