From 7ed9502290a03591c157fb6aa4c967d8d38b9472 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Thu, 6 Aug 2020 11:34:33 +0200 Subject: [PATCH] Add exceptions for invalid weight and length units --- MDErrorReporter.php | 1 + exceptions/updates/MDInvalidLengthUnit.php | 29 ++++++++++++++++++++++ exceptions/updates/MDInvalidLicense.php | 2 +- exceptions/updates/MDInvalidWeightUnit.php | 29 ++++++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 exceptions/updates/MDInvalidLengthUnit.php create mode 100644 exceptions/updates/MDInvalidWeightUnit.php diff --git a/MDErrorReporter.php b/MDErrorReporter.php index a63092e..b080cde 100644 --- a/MDErrorReporter.php +++ b/MDErrorReporter.php @@ -38,6 +38,7 @@ class MDErrorReporter { || $exception instanceof MDPageNotInAggregatedException || $exception instanceof MDWrongFileType || $exception instanceof MDTooManyFilesUploadException + || $exception instanceof MDgenericInvalidInputsException || $exception instanceof MDExpectedException || $exception instanceof MDMysqliExpectedError ) { diff --git a/exceptions/updates/MDInvalidLengthUnit.php b/exceptions/updates/MDInvalidLengthUnit.php new file mode 100644 index 0000000..037d3f1 --- /dev/null +++ b/exceptions/updates/MDInvalidLengthUnit.php @@ -0,0 +1,29 @@ + + */ +declare(strict_types = 1); + +/** + * Custom exception class to be raised when trying to use a length unit that is not + * accepted by museum-digital. + */ +class MDInvalidLengthUnit extends MDgenericInvalidInputsException { + + /** + * Error message. + * + * @return string + */ + public function errorMessage() { + //error message + $errorMsg = 'The following length unit is not available: ' . $this->getMessage(); + return $errorMsg; + + } + +} diff --git a/exceptions/updates/MDInvalidLicense.php b/exceptions/updates/MDInvalidLicense.php index 17a5786..8b03d55 100644 --- a/exceptions/updates/MDInvalidLicense.php +++ b/exceptions/updates/MDInvalidLicense.php @@ -12,7 +12,7 @@ declare(strict_types = 1); * Custom exception class to be raised when trying to use a license that is not * accepted by museum-digital. */ -class MDInvalidLicense extends Exception { +class MDInvalidLicense extends MDgenericInvalidInputsException { /** * Error message. diff --git a/exceptions/updates/MDInvalidWeightUnit.php b/exceptions/updates/MDInvalidWeightUnit.php new file mode 100644 index 0000000..584d63b --- /dev/null +++ b/exceptions/updates/MDInvalidWeightUnit.php @@ -0,0 +1,29 @@ + + */ +declare(strict_types = 1); + +/** + * Custom exception class to be raised when trying to use a weight unit that is not + * accepted by museum-digital. + */ +class MDInvalidWeightUnit extends MDgenericInvalidInputsException { + + /** + * Error message. + * + * @return string + */ + public function errorMessage() { + //error message + $errorMsg = 'The following weight unit is not available: ' . $this->getMessage(); + return $errorMsg; + + } + +}