Skip to content

Commit 2659e45

Browse files
committed
Updated error messages [skip ci]
1 parent faf4352 commit 2659e45

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

include/pgvector/sparsevec.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SparseVector {
2525
/// Creates a sparse vector from a span.
2626
explicit SparseVector(std::span<const float> value) {
2727
if (value.size() > std::numeric_limits<int>::max()) {
28-
throw std::invalid_argument{"too many dimensions"};
28+
throw std::invalid_argument{"sparsevec cannot have more than max int dimensions"};
2929
}
3030
dimensions_ = static_cast<int>(value.size());
3131

@@ -42,7 +42,7 @@ class SparseVector {
4242
/// Creates a sparse vector from a map of non-zero elements.
4343
SparseVector(const std::unordered_map<int, float>& map, int dimensions) {
4444
if (dimensions < 0) {
45-
throw std::invalid_argument{"sparsevec dimensions cannot be negative"};
45+
throw std::invalid_argument{"sparsevec cannot have negative dimensions"};
4646
}
4747
dimensions_ = dimensions;
4848

test/pqxx_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void test_sparsevec_from_string() {
258258

259259
assert_exception<pqxx::conversion_error>([] {
260260
auto _ = pqxx::from_string<pgvector::SparseVector>("{}/-1");
261-
}, "sparsevec dimensions cannot be negative");
261+
}, "sparsevec cannot have negative dimensions");
262262

263263
assert_exception<pqxx::conversion_error>([] {
264264
auto _ = pqxx::from_string<pgvector::SparseVector>("{:}/1");

test/sparsevec_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void test_constructor_map() {
2828

2929
assert_exception<std::invalid_argument>([&]{
3030
SparseVector(map, -1);
31-
}, "sparsevec dimensions cannot be negative");
31+
}, "sparsevec cannot have negative dimensions");
3232

3333
assert_exception<std::invalid_argument>([&]{
3434
SparseVector(map, 4);

0 commit comments

Comments
 (0)