From 72bfa3fb2c91a486e4bdedb4050b9c173d101959 Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Thu, 3 Aug 2023 14:52:30 +0200 Subject: [PATCH] create custom exceptions --- CRM/Twingle/Exceptions/BaseException.php | 43 +++++++++++++++++++ CRM/Twingle/Exceptions/ProfileException.php | 16 +++++++ .../Exceptions/ProfileValidationError.php | 34 +++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 CRM/Twingle/Exceptions/BaseException.php create mode 100644 CRM/Twingle/Exceptions/ProfileException.php create mode 100644 CRM/Twingle/Exceptions/ProfileValidationError.php diff --git a/CRM/Twingle/Exceptions/BaseException.php b/CRM/Twingle/Exceptions/BaseException.php new file mode 100644 index 0000000..f61a4fe --- /dev/null +++ b/CRM/Twingle/Exceptions/BaseException.php @@ -0,0 +1,43 @@ +log_message = !empty($message) ? E::LONG_NAME . ': ' . $message : ''; + $this->error_code = $error_code; + } + + /** + * Returns the error message, but with the extension name prefixed. + * @return string + */ + public function getLogMessage() { + return $this->log_message; + } + + /** + * Returns the error code. + * @return string + */ + public function getErrorCode() { + return $this->error_code; + } + +} diff --git a/CRM/Twingle/Exceptions/ProfileException.php b/CRM/Twingle/Exceptions/ProfileException.php new file mode 100644 index 0000000..1141d10 --- /dev/null +++ b/CRM/Twingle/Exceptions/ProfileException.php @@ -0,0 +1,16 @@ +affected_field_name = $affected_field_name; + } + + /** + * Returns the name of the profile field that caused the exception. + * @return string + */ + public function getAffectedFieldName() { + return $this->affected_field_name; + } + +}