Skip to content

Commit da8d60a

Browse files
committed
chore: deduplicate depth exceeded error
1 parent d854431 commit da8d60a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

google/cloud/bigtable/value.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,16 @@ std::ostream& operator<<(std::ostream& os, Value const& v) {
339339
return StreamHelper(os, v.value_, v.type_, StreamMode::kScalar);
340340
}
341341

342+
Status Value::MakeDepthExceededError() {
343+
return internal::InternalError("Nested value depth exceeds 10 levels");
344+
}
345+
342346
// NOLINTNEXTLINE(misc-no-recursion)
343347
Status Value::TypeAndArrayValuesMatch(google::bigtable::v2::Type const& type,
344348
google::bigtable::v2::Value const& value,
345349
int depth) {
346350
if (depth > 10) {
347-
return internal::InternalError("Nested value depth exceeds 10 levels");
351+
return MakeDepthExceededError();
348352
}
349353
if (!value.has_array_value()) {
350354
return internal::InternalError(
@@ -366,7 +370,7 @@ Status Value::TypeAndMapValuesMatch(google::bigtable::v2::Type const& type,
366370
google::bigtable::v2::Value const& value,
367371
int depth) {
368372
if (depth > 10) {
369-
return internal::InternalError("Nested value depth exceeds 10 levels");
373+
return MakeDepthExceededError();
370374
}
371375
if (!value.has_array_value()) {
372376
return internal::InternalError(
@@ -402,7 +406,7 @@ Status Value::TypeAndStructValuesMatch(google::bigtable::v2::Type const& type,
402406
google::bigtable::v2::Value const& value,
403407
int depth) {
404408
if (depth > 10) {
405-
return internal::InternalError("Nested value depth exceeds 10 levels");
409+
return MakeDepthExceededError();
406410
}
407411
if (!value.has_array_value()) {
408412
return internal::InternalError(
@@ -437,7 +441,7 @@ Status Value::TypeAndValuesMatch(google::bigtable::v2::Type const& type,
437441
google::bigtable::v2::Value const& value,
438442
int depth) {
439443
if (depth > 10) {
440-
return internal::InternalError("Nested value depth exceeds 10 levels");
444+
return MakeDepthExceededError();
441445
}
442446
using google::bigtable::v2::Type;
443447
auto make_mismatch_metadata_status = [&](std::string const& value_kind,

google/cloud/bigtable/value.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ class Value {
321321
}
322322

323323
private:
324+
static Status MakeDepthExceededError();
324325
static Status TypeAndValuesMatch(google::bigtable::v2::Type const& type,
325326
google::bigtable::v2::Value const& value,
326327
int depth);

0 commit comments

Comments
 (0)