Skip to content

Commit

Permalink
Merge pull request #819 from suketa/fix_error_messages
Browse files Browse the repository at this point in the history
update error messages.
  • Loading branch information
suketa authored Nov 23, 2024
2 parents e03afa7 + 4016878 commit eb7e5de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ext/duckdb/prepared_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ VALUE rbduckdb_prepared_statement_new(duckdb_connection con, duckdb_extracted_st
TypedData_Get_Struct(obj, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);

if (duckdb_prepare_extracted_statement(con, extracted_statements, index, &(ctx->prepared_statement)) == DuckDBError) {
rb_raise(eDuckDBError, "Failed to create DuckDB::PreparedStatement object.");
const char *error = duckdb_prepare_error(ctx->prepared_statement);
rb_raise(eDuckDBError, "%s", error ? error : "Failed to create DuckDB::PreparedStatement object.");
}
return obj;
}
Expand All @@ -90,7 +91,7 @@ static VALUE duckdb_prepared_statement_initialize(VALUE self, VALUE con, VALUE q

if (duckdb_prepare(ctxcon->con, StringValuePtr(query), &(ctx->prepared_statement)) == DuckDBError) {
const char *error = duckdb_prepare_error(ctx->prepared_statement);
rb_raise(eDuckDBError, "%s", error);
rb_raise(eDuckDBError, "%s", error ? error : "Failed to prepare statement(Database connection closed?).");
}
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion test/duckdb_test/database_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_close
con.query('SELECT * from DUMMY')
end

assert_equal('Failed to create DuckDB::PreparedStatement object.', exception.message)
assert_match(/DUMMY does not exist/, exception.message)
end

private
Expand Down

0 comments on commit eb7e5de

Please sign in to comment.