Skip to content

Commit 5493a28

Browse files
committed
FIX return 404 instead of 500 for invalid model class, fixes #570
1 parent 65c0adb commit 5493a28

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

code/ModelAdmin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace SilverStripe\Admin;
44

55
use InvalidArgumentException;
6+
use Psr\Log\LoggerInterface;
67
use SilverStripe\Control\Controller;
78
use SilverStripe\Control\HTTPRequest;
89
use SilverStripe\Control\HTTPResponse;
@@ -162,7 +163,8 @@ protected function init()
162163
$this->modelTab = $this->unsanitiseClassName($this->modelTab);
163164

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

0 commit comments

Comments
 (0)