当前位置: 首页>>代码示例>>PHP>>正文


PHP ApplicationException类代码示例

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


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

示例1: __construct

 public function __construct($errors = null, $message = null, $ApplicationExceptionType = null)
 {
     parent::__construct();
     $this->errors = $errors;
     $this->message = $message;
     $this->ApplicationExceptionType = $ApplicationExceptionType;
 }
开发者ID:sonicgd,项目名称:google-adwords-api-light,代码行数:7,代码来源:ApiException.php

示例2: addLogItem

 private function addLogItem($msg, $logType)
 {
     if (!$this->logFileName) {
         return null;
     }
     $logItem = array("type" => $logType, "msg" => $msg);
     $logData = microtime(true) . " | " . $this->createLogItemStr($logItem);
     file_put_contents($this->logFileName, $logData, FILE_APPEND);
     $e = new Exception();
     $this->lastTrace = ApplicationException::getFileTrace($e->getTrace());
     $this->lastQuery = $msg;
 }
开发者ID:saiber,项目名称:www,代码行数:12,代码来源:ARLogger.php

示例3: __construct

 function __construct($message, $code = null)
 {
     // Call ApplicationException constructor
     parent::__construct("Licensing error: {$message}");
 }
开发者ID:rchicoria,项目名称:epp-drs,代码行数:5,代码来源:class.LicensingException.php

示例4: __construct

 public function __construct($errors = NULL, $message = NULL, $ApplicationExceptionType = NULL)
 {
     if (get_parent_class('ApiException')) {
         parent::__construct();
     }
     $this->errors = $errors;
     $this->message = $message;
     $this->ApplicationExceptionType = $ApplicationExceptionType;
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:9,代码来源:CustomFieldService.php

示例5: run

	/**
	 * Dispatch a HTTP request to a front controller.
	 * @return void
	 */
	public function run()
	{
		$httpRequest = $this->getHttpRequest();
		$httpResponse = $this->getHttpResponse();

		// check HTTP method
		if ($this->allowedMethods) {
			$method = $httpRequest->getMethod();
			if (!in_array($method, $this->allowedMethods, TRUE)) {
				$httpResponse->setCode(Nette\Web\IHttpResponse::S501_NOT_IMPLEMENTED);
				$httpResponse->setHeader('Allow', implode(',', $this->allowedMethods));
				echo '<h1>Method ' . htmlSpecialChars($method) . ' is not implemented</h1>';
				return;
			}
		}

		// dispatching
		$request = NULL;
		$repeatedError = FALSE;
		do {
			try {
				if (count($this->requests) > self::$maxLoop) {
					throw new ApplicationException('Too many loops detected in application life cycle.');
				}

				if (!$request) {
					$this->onStartup($this);

					// autostarts session
					$session = $this->getSession();
					if (!$session->isStarted() && $session->exists()) {
						$session->start();
					}

					// routing
					$router = $this->getRouter();

					// enable routing debuggger
					Nette\Debug::addPanel(new RoutingDebugger($router, $httpRequest));

					$request = $router->match($httpRequest);
					if (!$request instanceof PresenterRequest) {
						$request = NULL;
						throw new BadRequestException('No route for HTTP request.');
					}

					if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
						throw new BadRequestException('Invalid request. Presenter is not achievable.');
					}
				}

				$this->requests[] = $request;
				$this->onRequest($this, $request);

				// Instantiate presenter
				$presenter = $request->getPresenterName();
				try {
					$class = $this->getPresenterLoader()->getPresenterClass($presenter);
					$request->setPresenterName($presenter);
				} catch (InvalidPresenterException $e) {
					throw new BadRequestException($e->getMessage(), 404, $e);
				}
				$request->freeze();

				// Execute presenter
				$this->presenter = new $class;
				$response = $this->presenter->run($request);
				$this->onResponse($this, $response);

				// Send response
				if ($response instanceof ForwardingResponse) {
					$request = $response->getRequest();
					continue;

				} elseif ($response instanceof IPresenterResponse) {
					$response->send();
				}
				break;

			} catch (\Exception $e) {
				// fault barrier
				$this->onError($this, $e);

				if (!$this->catchExceptions) {
					$this->onShutdown($this, $e);
					throw $e;
				}

				if ($repeatedError) {
					$e = new ApplicationException('An error occured while executing error-presenter', 0, $e);
				}

				if (!$httpResponse->isSent()) {
					$httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
				}

//.........这里部分代码省略.........
开发者ID:redhead,项目名称:nette,代码行数:101,代码来源:Application.php

示例6: run

 /**
  * Dispatch a HTTP request to a front controller.
  */
 public function run()
 {
     $httpRequest = $this->getHttpRequest();
     $httpResponse = $this->getHttpResponse();
     $httpRequest->setEncoding('UTF-8');
     $httpResponse->setHeader('X-Powered-By', 'Nette Framework');
     if (Environment::getVariable('baseUri') === NULL) {
         Environment::setVariable('baseUri', $httpRequest->getUri()->basePath);
     }
     // check HTTP method
     $method = $httpRequest->getMethod();
     if ($this->allowedMethods) {
         if (!in_array($method, $this->allowedMethods, TRUE)) {
             $httpResponse->setCode(IHttpResponse::S501_NOT_IMPLEMENTED);
             $httpResponse->setHeader('Allow', implode(',', $this->allowedMethods));
             $method = htmlSpecialChars($method);
             die("<h1>Method {$method} is not implemented</h1>");
         }
     }
     // dispatching
     $request = NULL;
     $hasError = FALSE;
     do {
         try {
             if (count($this->requests) > self::$maxLoop) {
                 throw new ApplicationException('Too many loops detected in application life cycle.');
             }
             if (!$request) {
                 $this->onStartup($this);
                 // default router
                 $router = $this->getRouter();
                 if ($router instanceof MultiRouter && !count($router)) {
                     $router[] = new SimpleRouter(array('presenter' => 'Default', 'action' => 'default'));
                 }
                 // routing
                 $request = $router->match($httpRequest);
                 if (!$request instanceof PresenterRequest) {
                     $request = NULL;
                     throw new BadRequestException('No route for HTTP request.');
                 }
                 if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
                     throw new BadRequestException('Invalid request.');
                 }
             }
             $this->requests[] = $request;
             $this->onRequest($this, $request);
             // Instantiate presenter
             $presenter = $request->getPresenterName();
             try {
                 $class = $this->getPresenterLoader()->getPresenterClass($presenter);
                 $request->modify('name', $presenter);
             } catch (InvalidPresenterException $e) {
                 throw new BadRequestException($e->getMessage(), 404, $e);
             }
             $this->presenter = new $class($request);
             // Instantiate topmost service locator
             $this->presenter->setServiceLocator(new ServiceLocator($this->serviceLocator));
             // Execute presenter
             $this->presenter->run();
             break;
         } catch (RedirectingException $e) {
             // not error, presenter redirects to new URL
             $httpResponse->redirect($e->getUri(), $e->getCode());
             break;
         } catch (ForwardingException $e) {
             // not error, presenter forwards to new request
             $request = $e->getRequest();
         } catch (AbortException $e) {
             // not error, application is correctly terminated
             unset($e);
             break;
         } catch (Exception $e) {
             // fault barrier
             if ($this->catchExceptions === NULL) {
                 $this->catchExceptions = Environment::isProduction();
             }
             if (!$this->catchExceptions) {
                 throw $e;
             }
             $this->onError($this, $e);
             if ($hasError) {
                 $e = new ApplicationException('An error occured while executing error-presenter', 0, $e);
             } elseif ($this->errorPresenter) {
                 $hasError = TRUE;
                 $request = new PresenterRequest($this->errorPresenter, PresenterRequest::FORWARD, array('exception' => $e));
                 continue;
             }
             if ($e instanceof BadRequestException) {
                 if (!$httpResponse->isSent()) {
                     $httpResponse->setCode($e->getCode());
                 }
                 echo "<title>404 Not Found</title>\n\n<h1>Not Found</h1>\n\n<p>The requested URL was not found on this server.</p>";
                 break;
             } else {
                 if (!$httpResponse->isSent()) {
                     $httpResponse->setCode(500);
                 }
//.........这里部分代码省略.........
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:101,代码来源:Application.php

示例7: run

 /**
  * Dispatch a HTTP request to a front controller.
  * @return void
  */
 public function run()
 {
     $httpRequest = $this->context->httpRequest;
     $httpResponse = $this->context->httpResponse;
     // check HTTP method
     if ($this->allowedMethods) {
         $method = $httpRequest->getMethod();
         if (!in_array($method, $this->allowedMethods, TRUE)) {
             $httpResponse->setCode(Nette\Http\IResponse::S501_NOT_IMPLEMENTED);
             $httpResponse->setHeader('Allow', implode(',', $this->allowedMethods));
             echo '<h1>Method ' . htmlSpecialChars($method) . ' is not implemented</h1>';
             return;
         }
     }
     // dispatching
     $request = NULL;
     $repeatedError = FALSE;
     do {
         try {
             if (count($this->requests) > self::$maxLoop) {
                 throw new ApplicationException('Too many loops detected in application life cycle.');
             }
             if (!$request) {
                 $this->onStartup($this);
                 // routing
                 $router = $this->getRouter();
                 // enable routing debugger
                 Diagnostics\RoutingPanel::initialize($this, $httpRequest);
                 $request = $router->match($httpRequest);
                 if (!$request instanceof Request) {
                     $request = NULL;
                     throw new BadRequestException('No route for HTTP request.');
                 }
                 if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
                     throw new BadRequestException('Invalid request. Presenter is not achievable.');
                 }
             }
             $this->requests[] = $request;
             $this->onRequest($this, $request);
             // Instantiate presenter
             $presenterName = $request->getPresenterName();
             try {
                 $this->presenter = $this->getPresenterFactory()->createPresenter($presenterName);
             } catch (InvalidPresenterException $e) {
                 throw new BadRequestException($e->getMessage(), 404, $e);
             }
             $this->getPresenterFactory()->getPresenterClass($presenterName);
             $request->setPresenterName($presenterName);
             $request->freeze();
             // Execute presenter
             $response = $this->presenter->run($request);
             $this->onResponse($this, $response);
             // Send response
             if ($response instanceof Responses\ForwardResponse) {
                 $request = $response->getRequest();
                 continue;
             } elseif ($response instanceof IResponse) {
                 $response->send($httpRequest, $httpResponse);
             }
             break;
         } catch (\Exception $e) {
             // fault barrier
             $this->onError($this, $e);
             if (!$this->catchExceptions) {
                 $this->onShutdown($this, $e);
                 throw $e;
             }
             if ($repeatedError) {
                 $e = new ApplicationException('An error occurred while executing error-presenter', 0, $e);
             }
             if (!$httpResponse->isSent()) {
                 $httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
             }
             if (!$repeatedError && $this->errorPresenter) {
                 $repeatedError = TRUE;
                 if ($this->presenter instanceof UI\Presenter) {
                     try {
                         $this->presenter->forward(":{$this->errorPresenter}:", array('exception' => $e));
                     } catch (AbortException $foo) {
                         $request = $this->presenter->getLastCreatedRequest();
                     }
                 } else {
                     $request = new Request($this->errorPresenter, Request::FORWARD, array('exception' => $e));
                 }
                 // continue
             } else {
                 // default error handler
                 if ($e instanceof BadRequestException) {
                     $code = $e->getCode();
                 } else {
                     $code = 500;
                     Nette\Diagnostics\Debugger::log($e, Nette\Diagnostics\Debugger::ERROR);
                 }
                 require __DIR__ . '/templates/error.phtml';
                 break;
             }
//.........这里部分代码省略.........
开发者ID:bazo,项目名称:Tatami,代码行数:101,代码来源:Application.php

示例8: dump_livecart_trace

function dump_livecart_trace(Exception $e)
{
    echo "<br/><strong>" . get_class($e) . " ERROR:</strong> " . $e->getMessage() . "\n\n";
    echo "<br /><strong>FILE TRACE:</strong><br />\n\n";
    echo ApplicationException::getFileTrace($e->getTrace());
    exit;
}
开发者ID:saiber,项目名称:www,代码行数:7,代码来源:index.php

示例9: run

 /**
  * Dispatch a HTTP request to a front controller.
  * @return void
  */
 public function run()
 {
     $httpRequest = $this->getHttpRequest();
     $httpResponse = $this->getHttpResponse();
     $httpRequest->setEncoding('UTF-8');
     $httpResponse->setHeader('X-Powered-By', 'Nette Framework');
     if (Environment::getVariable('baseUri') === NULL) {
         Environment::setVariable('baseUri', $httpRequest->getUri()->getBasePath());
     }
     // autostarts session
     $session = $this->getSession();
     if (!$session->isStarted() && $session->exists()) {
         $session->start();
     }
     // check HTTP method
     if ($this->allowedMethods) {
         $method = $httpRequest->getMethod();
         if (!in_array($method, $this->allowedMethods, TRUE)) {
             $httpResponse->setCode(IHttpResponse::S501_NOT_IMPLEMENTED);
             $httpResponse->setHeader('Allow', implode(',', $this->allowedMethods));
             echo '<h1>Method ' . htmlSpecialChars($method) . ' is not implemented</h1>';
             return;
         }
     }
     // dispatching
     $request = NULL;
     $repeatedError = FALSE;
     do {
         try {
             if (count($this->requests) > self::$maxLoop) {
                 throw new ApplicationException('Too many loops detected in application life cycle.');
             }
             if (!$request) {
                 $this->onStartup($this);
                 // default router
                 $router = $this->getRouter();
                 if ($router instanceof MultiRouter && !count($router)) {
                     $router[] = new SimpleRouter(array('presenter' => 'Default', 'action' => 'default'));
                 }
                 // routing
                 $request = $router->match($httpRequest);
                 if (!$request instanceof PresenterRequest) {
                     $request = NULL;
                     throw new BadRequestException('No route for HTTP request.');
                 }
                 if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
                     throw new BadRequestException('Invalid request.');
                 }
             }
             $this->requests[] = $request;
             $this->onRequest($this, $request);
             // Instantiate presenter
             $presenter = $request->getPresenterName();
             try {
                 $class = $this->getPresenterLoader()->getPresenterClass($presenter);
                 $request->setPresenterName($presenter);
             } catch (InvalidPresenterException $e) {
                 throw new BadRequestException($e->getMessage(), 404, $e);
             }
             $request->freeze();
             // Execute presenter
             $this->presenter = new $class();
             $response = $this->presenter->run($request);
             // Send response
             if ($response instanceof ForwardingResponse) {
                 $request = $response->getRequest();
                 continue;
             } elseif ($response instanceof IPresenterResponse) {
                 $response->send();
             }
             break;
         } catch (Exception $e) {
             // fault barrier
             if ($this->catchExceptions === NULL) {
                 $this->catchExceptions = Environment::isProduction();
             }
             $this->onError($this, $e);
             if (!$this->catchExceptions) {
                 $this->onShutdown($this, $e);
                 throw $e;
             }
             if ($repeatedError) {
                 $e = new ApplicationException('An error occured while executing error-presenter', 0, $e);
             }
             if (!$httpResponse->isSent()) {
                 $httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
             }
             if (!$repeatedError && $this->errorPresenter) {
                 $repeatedError = TRUE;
                 $request = new PresenterRequest($this->errorPresenter, PresenterRequest::FORWARD, array('exception' => $e));
                 // continue
             } else {
                 // default error handler
                 echo "<meta name='robots' content='noindex'>\n\n";
                 if ($e instanceof BadRequestException) {
                     echo "<title>404 Not Found</title>\n\n<h1>Not Found</h1>\n\n<p>The requested URL was not found on this server.</p>";
//.........这里部分代码省略.........
开发者ID:jaroslavlibal,项目名称:MDW,代码行数:101,代码来源:Application.php

示例10: run

 /**
  * Dispatch a HTTP request to a front controller.
  *
  * @return void
  */
 public function run()
 {
     $request = null;
     $repeatedError = false;
     do {
         try {
             if (count($this->requests) > self::$maxLoop) {
                 throw new ApplicationException('Too many loops detected in application life cycle.');
             }
             if (!$request) {
                 $this->onStartup($this);
                 $request = $this->router->match($this->httpRequest);
                 if (!$request instanceof Request) {
                     $request = null;
                     throw new BadRequestException('No route for HTTP request.');
                 }
                 if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
                     throw new BadRequestException('Invalid request. Presenter is not achievable.');
                 }
             }
             $this->requests[] = $request;
             $this->onRequest($this, $request);
             // Instantiate presenter
             $presenterName = $request->getPresenterName();
             try {
                 $this->presenter = $this->presenterFactory->createPresenter($presenterName);
             } catch (InvalidPresenterException $e) {
                 throw new BadRequestException($e->getMessage(), 404, $e);
             }
             $this->presenterFactory->getPresenterClass($presenterName);
             $request->setPresenterName($presenterName);
             $request->freeze();
             // Execute presenter
             $response = $this->presenter->run($request);
             if ($response) {
                 $this->onResponse($this, $response);
             }
             // Send response
             if ($response instanceof Responses\ForwardResponse) {
                 $request = $response->getRequest();
                 continue;
             } elseif ($response instanceof IResponse) {
                 $response->send($this->httpRequest, $this->httpResponse);
             }
             break;
         } catch (\Exception $e) {
             // fault barrier
             $this->onError($this, $e);
             if (!$this->catchExceptions) {
                 $this->onShutdown($this, $e);
                 throw $e;
             }
             if ($repeatedError) {
                 $e = new ApplicationException('An error occurred while executing error-presenter', 0, $e);
             }
             if (!$this->httpResponse->isSent()) {
                 $this->httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
             }
             if (!$repeatedError && $this->errorPresenter) {
                 $repeatedError = true;
                 if ($this->presenter instanceof UI\Presenter) {
                     try {
                         $this->presenter->forward(":{$this->errorPresenter}:", array('exception' => $e));
                     } catch (AbortException $foo) {
                         $request = $this->presenter->getLastCreatedRequest();
                     }
                 } else {
                     $request = new Request($this->errorPresenter, Request::FORWARD, array('exception' => $e));
                 }
                 // continue
             } else {
                 // default error handler
                 if ($e instanceof BadRequestException) {
                     $code = $e->getCode();
                 } else {
                     $code = 500;
                     Nette\Diagnostics\Debugger::log($e, Nette\Diagnostics\Debugger::ERROR);
                 }
                 require __DIR__ . '/templates/error.phtml';
                 break;
             }
         }
     } while (1);
     $this->onShutdown($this, isset($e) ? $e : null);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:90,代码来源:Application.php

示例11: trim

		function __construct ($message, $code = E_USER_WARNING)
	 	{
	 		$message = trim($message, ".");
	 		$message = "Registry error: {$message}";
	 		$message = trim($message, ".");
	 		parent::__construct($message, $code);		
	 	}
开发者ID:rchicoria,项目名称:epp-drs,代码行数:7,代码来源:class.RegistryException.php

示例12: __construct

 public function __construct()
 {
     $message = 'Not implemented';
     $backtrace = debug_backtrace(0, 2);
     if (isset($backtrace[1]['class'])) {
         $message .= ' yet. Called at ' . $backtrace[1]['class'] . '::' . $backtrace[1]['function'];
     }
     parent::__construct($message);
 }
开发者ID:extpoint,项目名称:yii2-core,代码行数:9,代码来源:NotImplementedException.php

示例13: __construct

 public function __construct(Controller $controller, $statusCode, $message = false)
 {
     $this->controller = $controller;
     $this->statusCode = $statusCode;
     if (!$message) {
         $action = $this->getController()->getRequest()->getControllerName() . '/' . $this->getController()->getRequest()->getActionName();
         $code = $this->getStatusCode() . ' (' . self::getCodeMeaning($this->getStatusCode()) . ')';
         $message = "Error accessing {$action}.\n {$code}";
     }
     parent::__construct($message);
 }
开发者ID:saiber,项目名称:www,代码行数:11,代码来源:HTTPStatusException.php

示例14:

 /**
  * @param string $argumentName
  * @param string $message
  */
 function __construct($argumentName, $message)
 {
     Assert::isScalar($argumentName);
     parent::__construct($message);
     $this->argumentName = $argumentName;
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:10,代码来源:ArgumentException.class.php

示例15: __construct

 /**
  * @param string $controller Controllers name
  */
 public function __construct($controllerName)
 {
     parent::__construct("Specified controller ({$controllerName}) does not exist");
     $this->controllerName = $controllerName;
 }
开发者ID:saiber,项目名称:www,代码行数:8,代码来源:ControllerNotFoundException.php


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