Improve exceptions#1
Conversation
src/Database/Validator/Structure.php
Outdated
| if(isset(self::$formats[$name])) { | ||
| if(self::$formats[$name]['type'] !== $type) { | ||
| throw new Exception('Format ("'.$name.'") not available for this attribute type ("'.$type.'")'); | ||
| throw new DatabaseException('Format ("'.$name.'") not available for this attribute type ("'.$type.'")'); |
There was a problem hiding this comment.
We dont need to expose these errors since a format is an internal database concept and the end-user can't really do anything with that this information. These exceptions are better just logged.
src/Database/Validator/Structure.php
Outdated
| } | ||
|
|
||
| throw new Exception('Unknown format validator: "'.$name.'"'); | ||
| throw new DatabaseException('Unknown format validator: "'.$name.'"'); |
src/Database/Query.php
Outdated
| $parsed[] = Query::parse($query); | ||
| } catch (\Throwable $th) { | ||
| throw new Exception("Invalid query: ${query}", previous: $th); | ||
| throw new DatabaseException("Invalid query: ${query}"); |
There was a problem hiding this comment.
We don't need to expose it. An end user cannot control the query ( or fix any syntax issues on their query )
| $collection = $this->silent(fn() => $this->getCollection($id)); | ||
| if (!$collection->isEmpty() && $id !== self::METADATA){ | ||
| throw new Duplicate('Collection ' . $id . ' Exists!'); | ||
| throw new DuplicateException('Collection ' . $id . ' Exists!'); |
There was a problem hiding this comment.
This is okay 👍
Apart from this, the other changes in the file are not required. filters are not something an end user can fix from the dashboard
| { | ||
| if (empty($this->namespace)) { | ||
| throw new Exception('Missing namespace'); | ||
| throw new DatabaseException('Missing namespace'); |
There was a problem hiding this comment.
Lets revert the changes in this file. Namespace, & missing database are not under the end user's control
src/Database/Adapter.php
Outdated
| { | ||
| if (empty($namespace)) { | ||
| throw new Exception('Missing namespace'); | ||
| throw new DatabaseException('Missing namespace'); |
There was a problem hiding this comment.
Lets revert the changes in this file. Missing namespace, missing database etc are not under the control of the end-user
…atabase into add-exception-class
No description provided.