[BE] Introduce c10::SyntaxError (#144647)

Which will be translated into Python's SyntaxError
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144647
Approved by: https://github.com/Skylion007
This commit is contained in:
Nikita Shulga 2025-01-12 12:52:39 -08:00 committed by PyTorch MergeBot
parent 3541d2a2aa
commit 9ae35b8bb1
2 changed files with 7 additions and 0 deletions

View file

@ -289,6 +289,12 @@ class C10_API OutOfMemoryError : public Error {
using Error::Error;
};
// Used for handling syntacitc erros in input arguments.
// They shuld turn into SytnaxError when the cross into Python
class C10_API SyntaxError : public Error {
using Error::Error;
};
// Base error type for all distributed errors.
// These turn into DistError when they cross into Python.
class C10_API DistError : public Error {

View file

@ -74,6 +74,7 @@ inline void PyErr_SetString(PyObject* type, const std::string& message) {
_CATCH_GENERIC_ERROR(TypeError, PyExc_TypeError, retstmnt) \
_CATCH_GENERIC_ERROR( \
NotImplementedError, PyExc_NotImplementedError, retstmnt) \
_CATCH_GENERIC_ERROR(SyntaxError, PyExc_SyntaxError, retstmnt) \
_CATCH_GENERIC_ERROR(LinAlgError, THPException_LinAlgError, retstmnt) \
_CATCH_GENERIC_ERROR( \
OutOfMemoryError, THPException_OutOfMemoryError, retstmnt) \