Skip to content

Commit e4f5203

Browse files
tenpercentpytorchmergebot
authored andcommitted
print available modules in predictor error message (pytorch#78101)
Summary: print available modules when throwing a module not found exception I believe that improves UX Differential Revision: D36580924 Pull Request resolved: pytorch#78101 Approved by: https://github.com/mikeiovine
1 parent 3a921f2 commit e4f5203

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

caffe2/predictor/predictor_utils.cc

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,22 @@ namespace caffe2 {
1010
namespace predictor_utils {
1111

1212
TORCH_API const NetDef& getNet(const MetaNetDef& def, const std::string& name) {
13+
std::string net_names;
14+
bool is_first = true;
1315
for (const auto& n : def.nets()) {
16+
if (!is_first) {
17+
net_names += ", ";
18+
}
19+
is_first = false;
20+
net_names += n.key();
1421
if (n.key() == name) {
1522
return n.value();
1623
}
1724
}
18-
CAFFE_THROW("Net not found: ", name);
25+
CAFFE_THROW("Net not found: ",
26+
name,
27+
"; available nets: ",
28+
net_names);
1929
}
2030

2131
std::unique_ptr<MetaNetDef> extractMetaNetDef(

0 commit comments

Comments
 (0)