Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
[FIX] Improving error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Glasl committed Jun 22, 2018
1 parent 46dc339 commit 4e7dde6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 9 additions & 1 deletion src/pages/MediaPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 4e7dde6

Please sign in to comment.