Skip to content

Worries about postgresql errors #2097

Description

@dylanfcsr

Hello, there is a concern about any errors from postgresql

$validation->setRules([ 'utilisateur' => [ 'rules' => 'required|is_unique[fake]', 'label' => 'Nom d\'utilisateur', 'errors' => [ 'is_unique' => 'Un nom d\'utilisateur identique existe déjà' ] ] ]);

I'm trying to simulate an error using wrong is_unique an explicit error should I return

<br /> <b>Fatal error</b>: Uncaught CodeIgniter\Format\Exceptions\FormatException: Failed to parse json string, error: &quot;{0}&quot;. in /var/www/html/sda-car/vendor/codeigniter4/framework/system/Format/Exceptions/FormatException.php:9 Stack trace: #0 /var/www/html/sda-car/vendor/codeigniter4/framework/system/Format/JSONFormatter.php(66): CodeIgniter\Format\Exceptions\FormatException::forInvalidJSON('Type is not sup...') #1 /var/www/html/sda-car/vendor/codeigniter4/framework/system/API/ResponseTrait.php(370): CodeIgniter\Format\JSONFormatter-&gt;format(Array) #2 /var/www/html/sda-car/vendor/codeigniter4/framework/system/API/ResponseTrait.php(123): CodeIgniter\Debug\Exceptions-&gt;format(Array) #3 /var/www/html/sda-car/vendor/codeigniter4/framework/system/Debug/Exceptions.php(164): CodeIgniter\Debug\Exceptions-&gt;respond(Array, 500) #4 [internal function]: CodeIgniter\Debug\Exceptions-&gt;exceptionHandler(Object(ErrorException)) #5 {main} thrown in <b>/var/www/html/sda-car/vendor/codeigniter4/framework/system/Format/Exceptions/FormatException.php</b> on line <b>9</b><br /> { "title": "ErrorException", "type": "ErrorException", "code": 500, "message": "Uncaught CodeIgniter\\Format\\Exceptions\\FormatException: Failed to parse json string, error: \"{0}\". in /var/www/html/sda-car/vendor/codeigniter4/framework/system/Format/Exceptions/FormatException.php:9\nStack trace:\n#0 /var/www/html/sda-car/vendor/codeigniter4/framework/system/Format/JSONFormatter.php(66): CodeIgniter\\Format\\Exceptions\\FormatException::forInvalidJSON('Type is not sup...')\n#1 /var/www/html/sda-car/vendor/codeigniter4/framework/system/API/ResponseTrait.php(370): CodeIgniter\\Format\\JSONFormatter->format(Array)\n#2 /var/www/html/sda-car/vendor/codeigniter4/framework/system/API/ResponseTrait.php(123): CodeIgniter\\Debug\\Exceptions->format(Array)\n#3 /var/www/html/sda-car/vendor/codeigniter4/framework/system/Debug/Exceptions.php(164): CodeIgniter\\Debug\\Exceptions->respond(Array, 500)\n#4 [internal function]: CodeIgniter\\Debug\\Exceptions->exceptionHandler(Object(ErrorException))\n#5 {main}\n thrown", "file": "/var/www/html/sda-car/vendor/codeigniter4/framework/system/Format/Exceptions/FormatException.php", "line": 9, "trace": [ { "function": "shutdownHandler", "class": "CodeIgniter\\Debug\\Exceptions", "type": "->", "args": [] } ] }

But here is the error that is returned following this error,

This error but returned for all the postgreesql errors for example during a form I was sending a string, while my column was a column of type number, so it is not possible but instead to have an explicit error it made me the same mistake

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions