Browse Source

Change InvalidPrimaryKeyException to render with http 500 code

Corey Taylor 5 years ago
parent
commit
5b3b2c0b57

+ 0 - 4
src/Datasource/Exception/InvalidPrimaryKeyException.php

@@ -23,8 +23,4 @@ use Cake\Core\Exception\Exception;
  */
 class InvalidPrimaryKeyException extends Exception
 {
-    /**
-     * @inheritDoc
-     */
-    protected $_defaultCode = 404;
 }

+ 0 - 2
src/Error/ExceptionRenderer.php

@@ -23,7 +23,6 @@ use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Exception\Exception as CakeException;
 use Cake\Core\Exception\MissingPluginException;
-use Cake\Datasource\Exception\InvalidPrimaryKeyException;
 use Cake\Datasource\Exception\PageOutOfBoundsException;
 use Cake\Datasource\Exception\RecordNotFoundException;
 use Cake\Event\Event;
@@ -108,7 +107,6 @@ class ExceptionRenderer implements ExceptionRendererInterface
         // Controller exceptions
         MissingActionException::class => 404,
         // Datasource exceptions
-        InvalidPrimaryKeyException::class => 404,
         PageOutOfBoundsException::class => 404,
         RecordNotFoundException::class => 404,
         // Http exceptions

+ 1 - 1
tests/TestCase/ExceptionsTest.php

@@ -166,7 +166,7 @@ class ExceptionsTest extends TestCase
             ['Cake\Database\Exception\MissingDriverException', 500],
             ['Cake\Database\Exception\MissingExtensionException', 500],
             ['Cake\Database\Exception\NestedTransactionRollbackException', 500],
-            ['Cake\Datasource\Exception\InvalidPrimaryKeyException', 404],
+            ['Cake\Datasource\Exception\InvalidPrimaryKeyException', 500],
             ['Cake\Datasource\Exception\MissingDatasourceConfigException', 500],
             ['Cake\Datasource\Exception\MissingDatasourceException', 500],
             ['Cake\Datasource\Exception\MissingModelException', 500],