本文整理汇总了PHP中Zend_Exception类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Exception类的具体用法?PHP Zend_Exception怎么用?PHP Zend_Exception使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Exception类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExceptions
public function testExceptions()
{
// Ohne Mail
$exception = new Kwf_Exception();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertTrue($view->debug);
$this->assertEquals($view->template, 'error.tpl');
// Mit Mail
Zend_Registry::get('config')->debug->error->log = true;
Kwf_Config::deleteValueCache('debug.error.log');
$exception = new Kwf_Exception();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertFalse($view->debug);
$this->assertEquals($view->template, 'error.tpl');
// Nicht-Kwf_Exception mit Mail
Zend_Registry::get('config')->debug->error->log = true;
Kwf_Config::deleteValueCache('debug.error.log');
$e = new Zend_Exception();
$exception = new Kwf_Exception_Other($e);
$view = $this->_processException($exception);
$this->assertEquals($view->message, $e->getMessage());
$this->assertFalse($view->debug);
$this->assertEquals($view->template, 'error.tpl');
Zend_Registry::get('config')->debug->error->log = false;
Kwf_Config::deleteValueCache('debug.error.log');
// Kwf_Exception_NoLog mit Debug
Zend_Registry::get('config')->debug->error->log = true;
Kwf_Config::deleteValueCache('debug.error.log');
$exception = new Kwf_Exception_NoLog();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertFalse($view->debug);
Zend_Registry::get('config')->debug->error->log = false;
Kwf_Config::deleteValueCache('debug.error.log');
$this->assertEquals($view->template, 'error.tpl');
// Kwf_Exception_NoLog ohne Debug
$exception = new Kwf_Exception_NoLog();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertTrue($view->debug);
$this->assertEquals($view->template, 'error.tpl');
// Kwf_Exception_NotFound
$exception = new Kwf_Exception_NotFound();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertEquals($view->template, 'error404.tpl');
// Nicht-Kwf_Exception
$exception = new Exception();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertEquals($view->template, 'error.tpl');
// ClientException
$exception = new Kwf_ClientException();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertEquals($view->template, 'error-client.tpl');
}
示例2: checkModifyException
public function checkModifyException(Zend_Exception $exception)
{
if (preg_match('/Duplicate entry.*for key (\'name\'|2)/i', $exception->getMessage())) {
$this->_setError('nameExists');
return false;
}
return true;
}
示例3: testToString
public function testToString()
{
$p = new Zend_Exception('p', 0);
$e = new Zend_Exception('e', 0, $p);
$s = $e->__toString();
$this->assertContains('p', $s);
$this->assertContains('Next', $s);
$this->assertContains('e', $s);
}
示例4: testExceptions
public function testExceptions()
{
// Ohne Mail
$exception = new Kwf_Exception();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertTrue($view->debug);
$this->assertEquals($view->template, 'error.tpl');
// Mit Mail
Kwf_Exception_Abstract::$logErrors = true;
$exception = new Kwf_Exception();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertFalse($view->debug);
$this->assertEquals($view->template, 'error.tpl');
// Nicht-Kwf_Exception mit Mail
Kwf_Exception_Abstract::$logErrors = true;
$e = new Zend_Exception();
$exception = new Kwf_Exception_Other($e);
$view = $this->_processException($exception);
$this->assertEquals($view->message, $e->getMessage());
$this->assertFalse($view->debug);
$this->assertEquals($view->template, 'error.tpl');
Kwf_Exception_Abstract::$logErrors = null;
// Kwf_Exception_NoLog mit Debug
Kwf_Exception_Abstract::$logErrors = true;
$exception = new Kwf_Exception_NoLog();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertFalse($view->debug);
Kwf_Exception_Abstract::$logErrors = null;
$this->assertEquals($view->template, 'error.tpl');
// Kwf_Exception_NoLog ohne Debug
$exception = new Kwf_Exception_NoLog();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertTrue($view->debug);
$this->assertEquals($view->template, 'error.tpl');
// Kwf_Exception_NotFound
$exception = new Kwf_Exception_NotFound();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertEquals($view->template, 'error404.tpl');
// Nicht-Kwf_Exception
$exception = new Exception();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertEquals($view->template, 'error.tpl');
// ClientException
$exception = new Kwf_ClientException();
$view = $this->_processException($exception);
$this->assertEquals($view->message, $exception->getMessage());
$this->assertEquals($view->template, 'error-client.tpl');
}
示例5: __construct
/**
* Create a new ServiceException.
*
* @return array An array containing a collection of
* Zend_Gdata_Gapps_Error objects.
*/
public function __construct($errors = null)
{
parent::__construct("Server errors encountered");
if ($errors !== null) {
$this->setErrors($errors);
}
}
示例6: __construct
public function __construct($message, $op1 = null, $op2 = null, $result = null)
{
$this->op1 = $op1;
$this->op2 = $op2;
$this->result = $result;
parent::__construct($message);
}
示例7: __construct
public function __construct($message = 'Server Error', $code = 400, $extra = null)
{
switch ($code) {
case 401:
if (null == $message) {
$message = 'Not Authorised';
}
break;
case 403:
if (null == $message) {
$message = 'Forbidden';
}
break;
case 404:
if (null == $message) {
$message = 'Not Found';
}
break;
case 405:
if (null == $message) {
$message = 'Method Not Allowed';
}
Zend_Controller_Front::getInstance()->getResponse()->setHeader('Allow', $extra['allowed_methods']);
break;
}
parent::__construct($message, $code);
}
示例8: __construct
public function __construct($message = '', $code = 0, Exception $previous = null)
{
if (Core_Registry::getMessage()->isTranslated($message)) {
$message = Core_Registry::getMessage()->translate($message);
}
parent::__construct($message, (int) $code, $previous);
}
示例9: __construct
/**
*
* @param String $msg The message
* @param int $code the HttpResponseCode for this exception
* @param \Exception $previous
* @param string $info Optional extra information on the exception
*/
public function __construct($msg = '', $code = 200, \Exception $previous = null, $info = null)
{
parent::__construct($msg, $code, $previous);
if ($info) {
$this->setInfo($info);
}
}
示例10: __construct
/**
*
* @param string $msg
* @param int $code
* @param Exception $previous
*/
public function __construct($msg = '', $code = 0, Exception $previous = null)
{
if (is_array($msg)) {
$code = $msg['type'];
$msg = $msg['message'];
}
parent::__construct($msg, $code, $previous);
}
示例11: __construct
public function __construct($message = null)
{
if (empty($message)) {
parent::__construct('There has been an error with your request. (400)', 400);
} else {
parent::__construct($message . ' (400)', 400);
}
}
示例12: getZmaxFile
/**
* Get the script where the exeption occurred
*
* @retun string the script name
*/
public function getZmaxFile()
{
if ($this->zmax_error) {
return $this->script;
} else {
return parent::getFile();
}
}
示例13: __construct
public function __construct($message = null)
{
if (empty($message)) {
parent::__construct('You are not authorized to view this page. (401)', 401);
} else {
parent::__construct($message . ' (401)', 401);
}
}
示例14: __construct
public function __construct($message = null)
{
if (empty($message)) {
parent::__construct('This page does not exist. (404)', 404);
} else {
parent::__construct($message . ' (404)', 404);
}
}
示例15:
/**
* Constructor
* @param string $message
* @param string $code
* @param int $type
*/
function __construct($message = 'Exception', $code = 0, $type = CS_Exception::MINOR_ERROR)
{
if (empty($code)) {
$code = crc32(get_class($this));
}
$this->_errType = $type;
parent::__construct($message, $code);
//self::makeExceptionLog($this);
}