mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 19:45:08 +00:00
LibSQL: Improve error handling
The handling of filesystem level errors was basically non-existing or consisting of `VERIFY_NOT_REACHED` assertions. Addressed this by * Adding `open` methods to `Heap` and `Database` which return errors. * Changing the interface of methods of these classes and clients downstream to propagate these errors. The constructors of `Heap` and `Database` don't open the underlying filesystem file anymore. The SQL statement handlers return an `SQLErrorCode::InternalError` error code if an error comes back from the lower levels. Note that some of these errors are things like duplicate index entry errors that should be caught before the SQL layer attempts to actually update the database. Added tests to catch attempts to open weird or non-existent files as databases. Finally, in between me writing this patch and submitting the PR the AK::Result<Foo, Bar> template got deprecated in favour of ErrorOr<Foo>. This resulted in more busywork.
This commit is contained in:
parent
108de5dea0
commit
001949d77a
15 changed files with 355 additions and 140 deletions
|
@ -141,6 +141,7 @@ void insert_and_get_to_and_from_hash_index(int num_keys)
|
|||
ScopeGuard guard([]() { unlink("/tmp/test.db"); });
|
||||
{
|
||||
auto heap = SQL::Heap::construct("/tmp/test.db");
|
||||
EXPECT(!heap->open().is_error());
|
||||
SQL::Serializer serializer(heap);
|
||||
auto hash_index = setup_hash_index(serializer);
|
||||
|
||||
|
@ -158,6 +159,7 @@ void insert_and_get_to_and_from_hash_index(int num_keys)
|
|||
|
||||
{
|
||||
auto heap = SQL::Heap::construct("/tmp/test.db");
|
||||
EXPECT(!heap->open().is_error());
|
||||
SQL::Serializer serializer(heap);
|
||||
auto hash_index = setup_hash_index(serializer);
|
||||
|
||||
|
@ -237,6 +239,7 @@ void insert_into_and_scan_hash_index(int num_keys)
|
|||
ScopeGuard guard([]() { unlink("/tmp/test.db"); });
|
||||
{
|
||||
auto heap = SQL::Heap::construct("/tmp/test.db");
|
||||
EXPECT(!heap->open().is_error());
|
||||
SQL::Serializer serializer(heap);
|
||||
auto hash_index = setup_hash_index(serializer);
|
||||
|
||||
|
@ -254,6 +257,7 @@ void insert_into_and_scan_hash_index(int num_keys)
|
|||
|
||||
{
|
||||
auto heap = SQL::Heap::construct("/tmp/test.db");
|
||||
EXPECT(!heap->open().is_error());
|
||||
SQL::Serializer serializer(heap);
|
||||
auto hash_index = setup_hash_index(serializer);
|
||||
Vector<bool> found;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue