Skip to content

Commit 79cffd5

Browse files
authored
out of range exception catching (#227)
1 parent 0172aeb commit 79cffd5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

csrc/cpu/neighbor_sample_cpu.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ sample(const torch::Tensor &colptr, const torch::Tensor &row,
117117
inline bool satisfy_time(const c10::Dict<node_t, torch::Tensor> &node_time_dict,
118118
const node_t &src_node_type, int64_t dst_time,
119119
int64_t src_node) {
120-
try { // Check whether src -> dst obeys the time constraint:
120+
try {
121+
// Check whether src -> dst obeys the time constraint
121122
const torch::Tensor &src_node_time = node_time_dict.at(src_node_type);
122123
return src_node_time.data_ptr<int64_t>()[src_node] <= dst_time;
123-
} catch (int err) { // If no time is given, fall back to normal sampling:
124+
} catch (const std::out_of_range& e) {
125+
// If no time is given, fall back to normal sampling
124126
return true;
125127
}
126128
}

0 commit comments

Comments
 (0)