• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP throwException函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中throwException函数的典型用法代码示例。如果您正苦于以下问题:PHP throwException函数的具体用法?PHP throwException怎么用?PHP throwException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了throwException函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: auth

 public function auth($authToken, $login = null, $password = null)
 {
     if (is_null($authToken)) {
         $soapHeader = new \SoapHeader('urn:zimbra', 'context');
         $params = array(ZimbraSoapClient::SoapVarArray(array('account' => $login, 'password' => $password)));
         $result = $this->__soapCall("AuthRequest", $params, null, $soapHeader);
         if (array_key_exists('authToken', $result)) {
             $this->authToken = $result['authToken'];
             return $this->authToken;
         } else {
             return false;
         }
     } else {
         $params = array(ZimbraSoapClient::SoapVarArray(array('authToken' => array('@verifyAccount' => 1, '%' => $authToken))));
         try {
             $result = $this->__soapCall("AuthRequest", $params, null, $soapHeader);
             $this->authToken = $result['authToken'];
             return $this->authToken;
         } catch (SoapFault $e) {
             if ($e->getMessage() == 'no valid authtoken present') {
                 return $this->auth(null, $login, $password);
             }
             throwException($e);
         }
     }
 }
开发者ID:micoli,项目名称:qd_mail,代码行数:26,代码来源:ZimbraSoapClient.php


示例2: run

 /**
  * 运行应用程序
  * @param string $do 动作名称
  * @param string $mo 模块名称
  * @return AdminCP
  */
 function run($do = NULL, $moduleClass = NULL)
 {
     $do === NULL && ($do = $this->action);
     $moduleClass === NULL && ($moduleClass = $this->module);
     //$mo == 'Logout' && Admin::logout(__SELF__);
     $moduleFile = iPATH . 'admin/' . $moduleClass . '.mo.php';
     if (is_file($moduleFile) || empty($mo)) {
         if (!class_exists($moduleClass)) {
             if (is_file($moduleFile)) {
                 include_once $moduleFile;
             } else {
                 $moduleClass = 'iAction';
             }
         }
         if (class_exists($moduleClass)) {
             $module = new $moduleClass($this);
             $method = 'do' . $do;
             //                $method = $do?'do'.$do:($ac?'action'.$ac:'');
             if (method_exists($module, $method)) {
                 if ($this->param === NULL) {
                     $module->{$method}();
                 } else {
                     $module->{$method}($this->param);
                 }
             } else {
                 throwException('应用程序运行出错.类 ' . $moduleClass . ' 中找不到方法定义:' . $method, 1003);
             }
         } else {
             throwException('应用程序运行出错.文件 ' . $moduleFile . ' 中找不到类定义:' . $moduleClass, 1002);
         }
     } else {
         throwException('应用程序运行出错.找不到文件:' . $moduleFile, 1001);
     }
     return $this;
 }
开发者ID:idreamsoft,项目名称:iCMS5.0,代码行数:41,代码来源:admincp.class.php


示例3: testMapExceptionHandling

 public function testMapExceptionHandling()
 {
     $maybeInt = Maybe::fromValue(1);
     $maybeIntPlusOne = $maybeInt->map(function ($i) {
         return throwException($i);
     });
     $this->assertInstanceOf('TMciver\\Functional\\Maybe\\Nothing', $maybeIntPlusOne);
 }
开发者ID:tmciver,项目名称:functional-php,代码行数:8,代码来源:MaybeFunctorTest.php


示例4: getPrice

 public function getPrice()
 {
     $price = $this->price()->get()->first();
     if (!isset($price)) {
         throwException('Price not set');
     }
     return $price;
 }
开发者ID:mage2,项目名称:core,代码行数:8,代码来源:Product.php


示例5: setContent

 public function setContent($value)
 {
     if ($value === null || is_string($value)) {
         $this->object->Content = $value;
         return $this;
     }
     throwException(new \Exception("Parameter value must be of type 'string'"));
 }
开发者ID:natino45,项目名称:smsghapi-php,代码行数:8,代码来源:TicketResponse.php


示例6: getFormatter

 /**
  * 
  * @param string $format, the response type
  * @return \api\models\ResponseFormatter
  * 
  */
 public static function getFormatter($format = Response::FORMAT_JSON)
 {
     $class = __NAMESPACE__ . "\\ResponseFormatter" . strtoupper($format);
     if (class_exists($class)) {
         return new $class();
     } else {
         throwException(new \Exception("Could not find Response formatter for {$format}", null, null));
     }
 }
开发者ID:logbon72,项目名称:pebble-movies-server,代码行数:15,代码来源:ResponseFormatterFactory.php


示例7: send

 public function send($to, $message)
 {
     $result = null;
     $message = Config::get('sms.prefix') . $message . Config::get('sms.suffix');
     if (false == SenderFactory::validate($to)) {
         throwException(new InvalidMobileNumberException("非法的手机号码:{$to}"));
     } else {
         $result = $this->doSend($to, $message);
         $this->log->info("发送短信", array('to' => $to, 'message' => $message, 'result' => $result));
     }
     return $result;
 }
开发者ID:xjtuwangke,项目名称:laravel-bundles,代码行数:12,代码来源:AbstractSender.php


示例8: create

 /**
  * @param array $args
  * @return Uploader
  */
 public static function create(array $args)
 {
     if (count($args) < 3) {
         throwException(new \Exception('Not enough arguments'));
     }
     if ($args[0] === 'image' && count($args) == 4) {
         return new ImageUploader($args[1], $args[2], $args[3]);
     }
     if ($args[0] === 'file' && count($args) == 4) {
         return new FileUploader($args[1], $args[2], $args[3]);
     }
 }
开发者ID:orsic,项目名称:bushido,代码行数:16,代码来源:UploaderFactory.php


示例9: store

 /**
  * Store a newly created theme in database.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $filePath = $this->handleImageUpload($request->file('theme_zip_file'));
     $zip = new \ZipArchive();
     if ($zip->open($filePath) === true) {
         $extractPath = base_path('themes');
         $zip->extractTo($extractPath);
         $zip->close();
     } else {
         throwException('Error in Zip Extract error.');
     }
     return redirect()->route('admin.theme.index');
 }
开发者ID:mage2,项目名称:laravel-ecommerce,代码行数:20,代码来源:ThemeController.php


示例10: getGlobal

 /**
  * 获取全局对象
  * @param $path
  * @param $className
  */
 public static function getGlobal($path, $className = null)
 {
     if (!is_object(self::$_global[$path])) {
         import($path);
         if (is_null($className)) {
             throwException('实例化对象名称不能为空 path : ' . $path);
         }
         if (!class_exists($className)) {
             throwException('对象不存在 : ' . $className);
         }
         self::$_global[$path] = new $className();
     }
     return self::$_global[$path];
 }
开发者ID:BGCX261,项目名称:zlskytakeorder-svn-to-git,代码行数:19,代码来源:Base.class.php


示例11: isConnected

 public function isConnected()
 {
     try {
         $this->ftp->systype();
     } catch (\FtpException $e) {
         if ($e->getMessage() == "Not connected to FTP server. Call connect() or ssl_connect() first.") {
             return false;
         } else {
             // @codeCoverageIgnoreStart
             throwException($e);
             // @codeCoverageIgnoreEnd
         }
     }
     return true;
 }
开发者ID:no-chris,项目名称:connector,代码行数:15,代码来源:Ftp.php


示例12: setOption

 /**
  * 设置缓存参数
  * @param array $options 要设置的缓存参数
  */
 protected function setOption($name, $value)
 {
     if (!is_string($name)) {
         throwException("不正确的参数名称 : {$name}");
     }
     $name = strtolower($name);
     if (array_key_exists($name, $this->getOption())) {
         $this->_options[$name] = $value;
     }
     if ($this->_options['cache_dir'] === null) {
         $this->setOption('cache_dir', $this->getTmpDir() . DIRECTORY_SEPARATOR);
     }
     if ($this->_options['page_dir'] === null) {
         $this->setOption('page_dir', $this->getTmpDir() . DIRECTORY_SEPARATOR);
     }
 }
开发者ID:phptian,项目名称:buick.agar.io,代码行数:20,代码来源:cache.php


示例13: cache

 /**
  * 获取cache实例
  *
  * @param string $conf 使用的缓存配置;
  *
  * @return \Foundation\Cache\Redis | \Foundation\Cache\Apc | \Foundation\Cache\File | \Foundation\Cache\Memcache
  */
 public function cache($conf = 'default_cache')
 {
     $config = is_array($conf) ? $conf : Config::get($conf);
     $driver = '\\Foundation\\Cache\\' . $config['driver'];
     if (isset(self::$cacheInstance[$conf])) {
         return self::$cacheInstance[$conf];
     } else {
         if ($config['on']) {
             self::$cacheInstance[$conf] = new $driver($config);
             return self::$cacheInstance[$conf];
         } else {
             throwException(Lang::get('_NOT_OPEN_', $conf));
             return false;
         }
     }
 }
开发者ID:phpdn,项目名称:framework,代码行数:23,代码来源:Model.php


示例14: edit_campain

 function edit_campain($id)
 {
     try {
         $campaign = $this->mailChimp->campaigns->getList(array('campaign_id' => $id));
         if ($campaign['total'] == 0) {
             throwException(lang('Campain not found', 'mail_chimp'));
         }
         $data = $this->mailChimp->campaigns->content($id);
         $model['html'] = preg_replace('/<center>(.|\\n)*<\\/center>/', '', $data['html']);
         $model = array_merge($model, $campaign);
         $lists = $this->mailChimp->lists->getList();
         \CMSFactory\assetManager::create()->setData('model', $model)->setData('lists', $lists)->renderAdmin('edit');
     } catch (Exception $exc) {
         showMessage($exc->getMessage(), FALSE, 'r');
         pjax('/admin/components/init_window/mail_chimp');
     }
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:17,代码来源:admin.php


示例15: locker

 /**
  * 获取Lock实例
  *
  * @param string|null $useCache 使用的锁的配置
  *
  * @return \Foundation\Lock\Redis | \Foundation\Lock\Memcache | \Foundation\Lock\File | false
  * @throws \Exception
  */
 public function locker($useCache = null)
 {
     is_null($useCache) && ($useCache = Config::get('locker_use_cache', 'default_cache'));
     static $_instance = array();
     $config = Config::get($useCache);
     if (isset($_instance[$useCache])) {
         return $_instance[$useCache];
     } else {
         if ($config['on']) {
             $lock = 'Foundation\\Lock\\' . $config['driver'];
             $_instance[$useCache] = new $lock($useCache);
             return $_instance[$useCache];
         } else {
             throwException(Lang::get('_NOT_OPEN_', $useCache));
             return false;
         }
     }
 }
开发者ID:phpdn,项目名称:framework,代码行数:26,代码来源:Controller.php


示例16: deleteGroup

 public function deleteGroup($gid, Request $request)
 {
     //if logged process otherwise go to login form
     $current_user = ParseUser::getCurrentUser();
     if (!$current_user) {
         return redirect()->route('login');
     }
     $query = new ParseQuery("Groups");
     try {
         $group = $query->get($gid);
         $owner = $group->get('user')->fetch();
         if ($current_user->getObjectId() != $owner->getObjectId() && $group->get('public') !== true) {
             throwException(401, "Sorry you don't have access to delete this group.");
         } else {
             $group->destroy();
             return redirect('/groups');
         }
     } catch (ParseException $ex) {
         // The object was not retrieved successfully.
         // error is a ParseException with an error code and message.
         echo $ex->getMessage();
     }
 }
开发者ID:samphomsopha,项目名称:codelab,代码行数:23,代码来源:GroupController.php


示例17: deleteEvent

 public function deleteEvent($id, Request $request)
 {
     $current_user = ParseUser::getCurrentUser();
     if (!$current_user) {
         return redirect()->route('login');
     }
     $query = new ParseQuery("Events");
     $query->includeKey('user');
     try {
         $event = $query->get($id);
         $owner = $event->get('user');
         if ($current_user->getObjectId() != $owner->getObjectId()) {
             throwException(401, "Sorry you don't have access to delete this event.");
         } else {
             $event->destroy();
             return redirect('/groups');
         }
     } catch (ParseException $ex) {
         // The object was not retrieved successfully.
         // error is a ParseException with an error code and message.
         echo $ex->getMessage();
     }
 }
开发者ID:samphomsopha,项目名称:codelab,代码行数:23,代码来源:EventController.php


示例18: error

 /**
  * 数据库操作执行错误
  * @param string $sql 错误的SQL语句
  * @access private
  */
 function error($sql)
 {
     throwException('SQL执行错误: <b>' . $sql . '</b><br /> 错误代码: <b>' . mysql_errno($this->connect) . '</b><br /> 错误信息: <b>' . mysql_error($this->connect) . '</b>', 4001);
 }
开发者ID:sanplit,项目名称:huishou,代码行数:9,代码来源:OrmMysqlParser.class.php


示例19: getRegister

 /**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function getRegister()
 {
     throwException("can't register directly for admin accounts");
     //return view('mage2::admin.auth.register');
 }
开发者ID:virendrayadav,项目名称:styleexpert,代码行数:10,代码来源:AuthController.php


示例20: gen

function gen()
{
    (yield 'foo');
    strlen("foo", "bar", throwException());
    (yield 'bar');
}
开发者ID:badlamer,项目名称:hhvm,代码行数:6,代码来源:generator_throwing_during_function_call.php



注:本文中的throwException函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP throwSQLError函数代码示例发布时间:2022-05-23
下一篇:
PHP throwError函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap