本文整理汇总了PHP中throwException函数的典型用法代码示例。如果您正苦于以下问题:PHP throwException函数的具体用法?PHP throwException怎么用?PHP throwException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了throwException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例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;
}
示例3: testMapExceptionHandling
public function testMapExceptionHandling()
{
$maybeInt = Maybe::fromValue(1);
$maybeIntPlusOne = $maybeInt->map(function ($i) {
return throwException($i);
});
$this->assertInstanceOf('TMciver\\Functional\\Maybe\\Nothing', $maybeIntPlusOne);
}
示例4: getPrice
public function getPrice()
{
$price = $this->price()->get()->first();
if (!isset($price)) {
throwException('Price not set');
}
return $price;
}
示例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'"));
}
示例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));
}
}
示例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;
}
示例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]);
}
}
示例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');
}
示例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];
}
示例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;
}
示例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);
}
}
示例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;
}
}
}
示例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');
}
}
示例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;
}
}
}