PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.5
Pods – Custom Content Types and Fields v2.8.23.5
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / tribe-common / src / Tribe / Exception.php
pods / tribe-common / src / Tribe Last commit date
Admin 1 week ago Ajax 1 week ago Asset 1 week ago Context 1 week ago Customizer 1 week ago Debug_Bar 1 week ago Dialog 1 week ago Documentation 1 week ago Duplicate 1 week ago Editor 1 week ago Image 1 week ago JSON_LD 1 week ago Languages 1 week ago Log 1 week ago Meta 1 week ago Models 1 week ago PUE 1 week ago Process 1 week ago Promoter 1 week ago REST 1 week ago Repository 1 week ago Service_Providers 1 week ago Shortcode 1 week ago Support 1 week ago Tabbed_View 1 week ago Tooltip 1 week ago Traits 1 week ago Utils 1 week ago Validator 1 week ago Widget 1 week ago Abstract_Deactivation.php 1 week ago Abstract_Plugin_Register.php 1 week ago App_Shop.php 1 week ago Assets.php 1 week ago Assets_Pipeline.php 1 week ago Autoloader.php 1 week ago Cache.php 1 week ago Cache_Listener.php 1 week ago Changelog_Reader.php 1 week ago Container.php 1 week ago Context.php 1 week ago Cost_Utils.php 1 week ago Credits.php 1 week ago Customizer.php 1 week ago DB_Lock.php 1 week ago Data.php 1 week ago Date_Utils.php 1 week ago Db.php 1 week ago Debug.php 1 week ago Dependency.php 1 week ago Deprecation.php 1 week ago Editor.php 1 week ago Error.php 1 week ago Exception.php 1 week ago Extension.php 1 week ago Extension_Loader.php 1 week ago Feature_Detection.php 1 week ago Field.php 1 week ago Field_Conditional.php 1 week ago Freemius.php 1 week ago Log.php 1 week ago Main.php 1 week ago Notices.php 1 week ago Plugin_Meta_Links.php 1 week ago Plugins.php 1 week ago Plugins_API.php 1 week ago Post_History.php 1 week ago Post_Transient.php 1 week ago Promise.php 1 week ago Repository.php 1 week ago Rewrite.php 1 week ago Settings.php 1 week ago Settings_Manager.php 1 week ago Settings_Tab.php 1 week ago Simple_Table.php 1 week ago Support.php 1 week ago Tabbed_View.php 1 week ago Template.php 1 week ago Template_Factory.php 1 week ago Template_Part_Cache.php 1 week ago Templates.php 1 week ago Terms.php 1 week ago Timezones.php 1 week ago Tracker.php 1 week ago Updater.php 1 week ago Validate.php 1 week ago View_Helpers.php 1 week ago
Exception.php
91 lines
1 <?php
2
3
4 /**
5 * Class Tribe__Exception
6 *
7 * Handles exceptions to log when not in debug mode.
8 */
9 class Tribe__Exception extends Exception {
10
11 /**
12 * @var Exception
13 */
14 private $original_exception;
15
16 /**
17 * Tribe__Exception constructor.
18 *
19 * @param Exception $original_exception
20 */
21 public function __construct( Exception $original_exception ) {
22 $this->original_exception = $original_exception;
23 }
24
25 /**
26 * Handles the exception throwing the original when debugging (`WP_DEBUG` defined and `true`)
27 * or quietly logging when `WP_DEBUG` is `false` or not set.
28 *
29 * @return bool `true` if the message was logged, `false` otherwise.
30 *
31 * @throws Exception
32 */
33 public function handle() {
34 $debug = defined( 'WP_DEBUG' ) && WP_DEBUG;
35
36 if ( $debug ) {
37 $this->throw_original_exception();
38 }
39
40 return $this->log_original_exception_message();
41 }
42
43 /**
44 * @return string
45 */
46 private function get_log_type_for_exception_code( $code ) {
47 $map = array(
48 // @todo [BTRIA-583]: Let's add a decent exception code to log type map here.
49 );
50
51 return isset( $map[ $code ] ) ? $map[ $code ] : Tribe__Log::ERROR;
52 }
53
54 /**
55 * Throws the original exception.
56 *
57 * Provided as a manual override over the default `WP_DEBUG` dependent behaviour.
58 *
59 * @see Tribe__Exception::handle()
60 *
61 * @throws Exception
62 */
63 public function throw_original_exception() {
64 throw $this->original_exception;
65 }
66
67 /**
68 * Logs the original exception message.
69 *
70 * Provided as a manual override over the default `WP_DEBUG` dependent behaviour.
71 *
72 * @see Tribe__Exception::handle()
73 *
74 * @return bool `true` if the message was logged, `false` otherwise.
75 */
76 private function log_original_exception_message() {
77 if ( ! class_exists( 'Tribe__Log' ) ) {
78 return false;
79 }
80
81 $logger = new Tribe__Log();
82 $message = $this->original_exception->getMessage();
83 $log_type = $this->get_log_type_for_exception_code( $this->original_exception->getCode() );
84 $src = $this->original_exception->getFile() . ':' . $this->original_exception->getLine();
85
86 $logger->log( $message, $log_type, $src );
87
88 return true;
89 }
90 }
91