Skip to content

Commit

Permalink
FIX return 404 instead of 500 for invalid model class, fixes #570
Browse files Browse the repository at this point in the history
  • Loading branch information
xini committed May 28, 2024
1 parent 65c0adb commit 5493a28
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion code/ModelAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\Admin;

use InvalidArgumentException;
use Psr\Log\LoggerInterface;
use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
Expand Down Expand Up @@ -162,7 +163,8 @@ protected function init()
$this->modelTab = $this->unsanitiseClassName($this->modelTab);

if (!$this->isManagedModel($this->modelTab)) {
throw new \RuntimeException(sprintf('ModelAdmin::init(): Invalid Model class %s', $this->modelTab));
Injector::inst()->get(LoggerInterface::class)->error(sprintf('ModelAdmin::init(): Invalid Model class %s', $this->modelTab));
return $this->httpError(404, 'Page not found');
}
}

Expand Down

0 comments on commit 5493a28

Please sign in to comment.