Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
 1: <?php
 2: /**
 3:  * This file contains the cException class.
 4:  *
 5:  * @package Core
 6:  * @subpackage Exception
 7:  * @version SVN Revision $Rev:$
 8:  *
 9:  * @author Simon Sprankel
10:  * @copyright four for business AG <www.4fb.de>
11:  * @license http://www.contenido.org/license/LIZENZ.txt
12:  * @link http://www.4fb.de
13:  * @link http://www.contenido.org
14:  */
15: 
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17: 
18: /**
19:  * cException is the base class for all exceptions.
20:  * You should use this CONTENIDO exception instead of the standard PHP
21:  * {@link Exception}.
22:  * This exception type is logged to data/logs/exception.txt.
23:  * If there is a more specific and more appropriate subclass, use the subclass!
24:  */
25: class cException extends Exception {
26: 
27:     /**
28:      * Defines if an exception if this type should be logged.
29:      * May be defined by any exception individually.
30:      * 
31:      * @see CON-1690
32:      * @var bool
33:      */
34:     protected $_log_exception = false;
35:     
36:     /**
37:      * Saves an instance of the logger class for logging exceptions in the
38:      * corresponding log.
39:      *
40:      * @var cLog the logger instance
41:      */
42:     protected $_logger = NULL;
43: 
44:     /**
45:      * Constructs the Exception.
46:      *
47:      * @param string $message The Exception message to throw.
48:      * @param int $code The Exception code.
49:      * @param Exception $previous The previous exception used for the exception
50:      *            chaining.
51:      * @param array $options exception logging options. By default cExceptions
52:      *            are not logged but cErrorExceptions are
53:      */
54:     public function __construct($message, $code = 0, Exception $previous = NULL) {
55:         parent::__construct($message, $code, $previous);
56: 
57:         // create a logger class and save it for all logging purposes
58:         $cfg = cRegistry::getConfig();
59:         $writer = cLogWriter::factory("File", array(
60:             'destination' => $cfg['path']['contenido_logs'] . 'exception.txt'
61:         ));
62:         $this->_logger = new cLog($writer);
63: 
64:         // determine if exception should be logged
65:         if (false === $this->_log_exception
66:         && isset($cfg['debug']['log_exceptions'])) {
67:             $this->_log_exception = $cfg['debug']['log_exceptions'];
68:         }
69: 
70:         // log the exception if it should be logged
71:         if (true === $this->_log_exception) {
72:             $this->log();
73:         }
74:     }
75: 
76:     /**
77:      * Logs this exception no matter if the log flag is set or not.
78:      */
79:     public function log() {
80:         // construct the log message with all infos and write it via the logger
81:         $logMessage = get_class($this) . ' thrown at line ' . $this->getLine() . ' of file ' . $this->getFile() . ".\r\n";
82:         $logMessage .= 'Exception message: ' . $this->getMessage() . "\r\n";
83:         $logMessage .= "Call stack:\r\n";
84:         $logMessage .= $this->getTraceAsString();
85:         $logMessage .= "\r\n";
86:         $this->_logger->log($logMessage);
87:     }
88: 
89: }
90: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen