Skip to content

Commit f4b2c1f

Browse files
authored
Return result from get_backend_name
1 parent 2d6d981 commit f4b2c1f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

runtime/executor/method_meta.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,15 @@ size_t MethodMeta::num_backends() const {
245245
return delegates ? delegates->size() : 0;
246246
}
247247

248-
const char* MethodMeta::get_backend_name(size_t index) const {
249-
const auto delegates = s_plan_->delegates();
250-
if (delegates && index < delegates->size()) {
251-
return delegates->Get(index)->id()->c_str();
252-
}
253-
return nullptr;
248+
Result<const char*> MethodMeta::get_backend_name(size_t index) const {
249+
const auto count = num_backends();
250+
ET_CHECK_OR_RETURN_ERROR(
251+
index < count,
252+
InvalidArgument,
253+
"Index %zu out of range. num_backends: %zu",
254+
index,
255+
count);
256+
return s_plan_->delegates()->Get(index)->id()->c_str();
254257
}
255258

256259
size_t MethodMeta::num_instructions() const {

0 commit comments

Comments
 (0)