Skip to content

Commit

Permalink
Use std::invalid_argument -> ValueError for config errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ihnorton committed Jul 17, 2020
1 parent 55bee6a commit 689c60b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tiledb/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class PyQuery {
std::stoull(tmp_str);
} catch (const std::invalid_argument &e) {
(void)e;
throw TileDBError("Failed to convert 'py.init_buffer_bytes' to uint64_t ('" + tmp_str + "')");
throw std::invalid_argument("Failed to convert 'py.init_buffer_bytes' to uint64_t ('" + tmp_str + "')");
}
}

Expand All @@ -280,7 +280,7 @@ class PyQuery {
std::stoull(tmp_str);
} catch (const std::invalid_argument &e) {
(void)e;
throw TileDBError("Failed to convert 'py.exp_alloc_max_bytes' to uint64_t ('" + tmp_str + "')");
throw std::invalid_argument("Failed to convert 'py.exp_alloc_max_bytes' to uint64_t ('" + tmp_str + "')");
}
}

Expand All @@ -291,7 +291,7 @@ class PyQuery {
} else if (tmp_str == "false") {
deduplicate_ = false;
} else {
throw TileDBError("Failed to convert configuration 'py.deduplicate' to bool ('" + tmp_str + "')");
throw std::invalid_argument("Failed to convert configuration 'py.deduplicate' to bool ('" + tmp_str + "')");
}
}

Expand Down
4 changes: 4 additions & 0 deletions tiledb/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def test_pyquery_basic(self):
pass

with tiledb.open(uri) as a:
with self.assertRaises(ValueError):
testctx = tiledb.Ctx(config={'py.init_buffer_bytes': 'abcd'})
core.PyQuery(testctx, a, ("",), False, 0)

q = core.PyQuery(ctx, a, ("",), False, 0)

try:
Expand Down

0 comments on commit 689c60b

Please sign in to comment.