mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00:00
LibSQL+SQLServer: Return a NonnullRefPtr from Database::get_schema
Database::get_schema currently either returns a RefPtr to an existing schema, a nullptr if the schema doesn't exist, or an Error if some internal error occured. Change this to return a NonnullRefPtr to an exisiting schema, or a SQL::Result with any error, including if the schema was not found. Callers can then handle that specific error code if they want. Returning a NonnullRefPtr will enable some further cleanup. This had some fallout of needing to change some other methods' return types from AK::ErrorOr to SQL::Result so that TRY may continue to be used.
This commit is contained in:
parent
7464dfa974
commit
56843baff9
7 changed files with 49 additions and 57 deletions
|
@ -41,7 +41,7 @@ DatabaseConnection::DatabaseConnection(String database_name, int client_id)
|
|||
m_database = SQL::Database::construct(String::formatted("/home/anon/sql/{}.db", m_database_name));
|
||||
auto client_connection = ConnectionFromClient::client_connection_for(m_client_id);
|
||||
if (auto maybe_error = m_database->open(); maybe_error.is_error()) {
|
||||
client_connection->async_connection_error(m_connection_id, (int)SQL::SQLErrorCode::InternalError, maybe_error.error().string_literal());
|
||||
client_connection->async_connection_error(m_connection_id, to_underlying(maybe_error.error().error()), maybe_error.error().error_string());
|
||||
return;
|
||||
}
|
||||
m_accept_statements = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue