本文整理匯總了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;
}
}
}