From 4e7dde685ab669015380def521e0030f23bdd82b Mon Sep 17 00:00:00 2001 From: Nathan Glasl Date: Fri, 22 Jun 2018 15:20:28 +1000 Subject: [PATCH] [FIX] Improving error messages. --- README.md | 2 +- src/pages/MediaPage.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 09c3dfd..510b7fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [mediawesome](https://packagist.org/packages/nglasl/silverstripe-mediawesome) -_The current release is **4.0.2**_ +_The current release is **4.0.3**_ > This module allows creation of dynamic media holders/pages with CMS customisable types and attributes (blogs, events, news, publications), including versioning. diff --git a/src/pages/MediaPage.php b/src/pages/MediaPage.php index ee1e73b..8ae3645 100644 --- a/src/pages/MediaPage.php +++ b/src/pages/MediaPage.php @@ -328,7 +328,15 @@ public function validate() { // Customise a validation error message. - $message = is_numeric($this->URLSegment) ? '"URL Segment" must not be numeric!' : 'Invalid media holder!'; + if(is_numeric($this->URLSegment)) { + $message = '"URL Segment" must not be numeric!'; + } + else if(!($parent instanceof MediaHolder)) { + $message = 'The parent needs to be a published media holder!'; + } + else { + $message = "The media holder type doesn't match this!"; + } $error = new HTTPResponse_Exception($message, 403); $error->getResponse()->addHeader('X-Status', rawurlencode($message));