[clang] #101784 part 2: fix error handling of TranslationUnit.reparse (PR #102410)

Jannick Kremer via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 8 07:00:29 PDT 2024


================
@@ -152,6 +152,41 @@ def b(x: str | bytes) -> bytes:
 ### Exception Classes ###
 
 
+class CXError(Exception):
+    '''Represents C error of type enum CXErrorCode.'''
+
+    # A generic error code, no further details are available.
+    #
+    # Errors of this kind can get their own specific error codes in future
+    # libclang versions.
+    ERROR_FAILURE = 1
+
+    # libclang crashed while performing the requested operation.
+    ERROR_CRASHED = 2
+
+    # The function detected that the arguments violate the function
+    # contract.
+    ERROR_INVALID_ARGUMENTS = 3
+
+    # An AST deserialization error has occurred.
+    ERROR_AST_READ_ERROR = 4
+
+    error_code: int
----------------
DeinAlptraum wrote:

The type hint shouldn't be necessary, as the instance variable is initialized with an annotated type in the `__init__`

https://github.com/llvm/llvm-project/pull/102410


More information about the cfe-commits mailing list