action-exception.php
4 years ago
condition-exception.php
4 years ago
condition-silence-exception.php
4 years ago
gateway-exception.php
4 years ago
handler-exception.php
4 years ago
integration-exception.php
4 years ago
parse-exception.php
4 years ago
plain-default-exception.php
4 years ago
preset-exception.php
4 years ago
request-exception.php
4 years ago
silence-exception.php
4 years ago
handler-exception.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Exceptions; |
| 5 | |
| 6 | use Jet_Form_Builder\Dev_Mode\Logger; |
| 7 | use Jet_Form_Builder\Form_Messages\Manager; |
| 8 | |
| 9 | abstract class Handler_Exception extends \Exception { |
| 10 | |
| 11 | protected $default_type_message = 'failed'; |
| 12 | protected $dynamic_message = ''; |
| 13 | |
| 14 | protected $additional_data; |
| 15 | |
| 16 | public function __construct( $message = '', ...$additional_data ) { |
| 17 | parent::__construct( $message, 0, null ); |
| 18 | |
| 19 | $this->additional_data = $additional_data; |
| 20 | |
| 21 | if ( $this->save_exception() ) { |
| 22 | Logger::instance()->log( $this ); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | public function save_exception(): bool { |
| 27 | return true; |
| 28 | } |
| 29 | |
| 30 | public function dynamic_success(): Handler_Exception { |
| 31 | $this->message = Manager::dynamic_success( $this->message ); |
| 32 | |
| 33 | return $this; |
| 34 | } |
| 35 | |
| 36 | public function dynamic_error(): Handler_Exception { |
| 37 | $this->message = Manager::dynamic_error( $this->message ); |
| 38 | |
| 39 | return $this; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | public function get_form_status() { |
| 44 | return $this->message ? $this->message : $this->default_type_message; |
| 45 | } |
| 46 | |
| 47 | public function get_additional() { |
| 48 | return $this->additional_data; |
| 49 | } |
| 50 | |
| 51 | } |
| 52 |