PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.9.19.4
Pods – Custom Content Types and Fields v2.9.19.4
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 2 weeks ago Ajax 2 weeks ago Asset 2 weeks ago Context 2 weeks ago Customizer 2 weeks ago Debug_Bar 2 weeks ago Dialog 2 weeks ago Documentation 2 weeks ago Duplicate 2 weeks ago Editor 2 weeks ago Image 2 weeks ago JSON_LD 2 weeks ago Languages 2 weeks ago Log 2 weeks ago Meta 2 weeks ago Models 2 weeks ago PUE 2 weeks ago Process 2 weeks ago Promoter 2 weeks ago REST 2 weeks ago Repository 2 weeks ago Service_Providers 2 weeks ago Shortcode 2 weeks ago Support 2 weeks ago Tabbed_View 2 weeks ago Tooltip 2 weeks ago Traits 2 weeks ago Utils 2 weeks ago Validator 2 weeks ago Widget 2 weeks ago Abstract_Deactivation.php 2 weeks ago Abstract_Plugin_Register.php 2 weeks ago App_Shop.php 2 weeks ago Assets.php 2 weeks ago Assets_Pipeline.php 2 weeks ago Autoloader.php 2 weeks ago Cache.php 2 weeks ago Cache_Listener.php 2 weeks ago Changelog_Reader.php 2 weeks ago Container.php 2 weeks ago Context.php 2 weeks ago Cost_Utils.php 2 weeks ago Credits.php 2 weeks ago Customizer.php 2 weeks ago DB_Lock.php 2 weeks ago Data.php 2 weeks ago Date_Utils.php 2 weeks ago Db.php 2 weeks ago Debug.php 2 weeks ago Dependency.php 2 weeks ago Deprecation.php 2 weeks ago Editor.php 2 weeks ago Error.php 2 weeks ago Exception.php 2 weeks ago Extension.php 2 weeks ago Extension_Loader.php 2 weeks ago Feature_Detection.php 2 weeks ago Field.php 2 weeks ago Field_Conditional.php 2 weeks ago Freemius.php 2 weeks ago Log.php 2 weeks ago Main.php 2 weeks ago Notices.php 2 weeks ago Plugin_Meta_Links.php 2 weeks ago Plugins.php 2 weeks ago Plugins_API.php 2 weeks ago Post_History.php 2 weeks ago Post_Transient.php 2 weeks ago Promise.php 2 weeks ago Repository.php 2 weeks ago Rewrite.php 2 weeks ago Settings.php 2 weeks ago Settings_Manager.php 2 weeks ago Settings_Tab.php 2 weeks ago Simple_Table.php 2 weeks ago Support.php 2 weeks ago Tabbed_View.php 2 weeks ago Template.php 2 weeks ago Template_Factory.php 2 weeks ago Template_Part_Cache.php 2 weeks ago Templates.php 2 weeks ago Terms.php 2 weeks ago Timezones.php 2 weeks ago Tracker.php 2 weeks ago Updater.php 2 weeks ago Validate.php 2 weeks ago View_Helpers.php 2 weeks 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