bdsoha commented on code in PR #27319:
URL: https://github.com/apache/airflow/pull/27319#discussion_r1015061958


##########
airflow/providers/oracle/operators/oracle.py:
##########
@@ -98,7 +102,9 @@ def execute(self, context: Context):
         try:
             return hook.callproc(self.procedure, autocommit=True, 
parameters=self.parameters)
         except oracledb.DatabaseError as e:
-            code, mesg = e.args[0].message[:-1].split(": ", 1)
-            if self.do_xcom_push:
-                ti.xcom_push(key="ORA", value=str(code.split("-")[1]))
+            code_match = re.search("^ORA-(\\d+):.+", str(e))
+            if code_match is not None:
+                if self.do_xcom_push:
+                    if ti is not None:
+                        ti.xcom_push(key="ORA", value=code_match.group(1))

Review Comment:
   IMO, this is cognitively complex.
   
   ```suggestion
               if code_match and self.do_xcom_push and ti:
                   ti.xcom_push(key="ORA", value=code_match.group(1))
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to