[Exception] [4/N] Replace torch::IndexError and torch::ValueError with C10 counterparts (#117317)

Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/117317
Approved by: https://github.com/ezyang
This commit is contained in:
cyy
2024-01-18 00:35:29 +00:00
committed by PyTorch MergeBot
parent c64fd8b89c
commit 396a5c3091
10 changed files with 124 additions and 122 deletions

View File

@ -355,12 +355,13 @@ inline PythonArgs PythonArgParser::parse(
PyObject* args,
PyObject* kwargs,
ParsedArgs<N>& dst) {
if (N < max_args) {
throw ValueError(
"PythonArgParser: dst ParsedArgs buffer does not have enough capacity, expected %d (got %d)",
(int)max_args,
N);
}
TORCH_CHECK_VALUE(
N >= max_args,
"PythonArgParser: dst ParsedArgs buffer does not have enough capacity, expected ",
max_args,
" (got ",
N,
")");
return raw_parse(self, args, kwargs, dst.args);
}