You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/10/28 17:17:47 UTC

[GitHub] [airflow] kolfild26 commented on a diff in pull request #27319: XCOM push ORA error code in OracleStoredProcedure

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


##########
airflow/providers/oracle/operators/oracle.py:
##########
@@ -93,4 +95,10 @@ def __init__(
     def execute(self, context: Context):
         self.log.info("Executing: %s", self.procedure)
         hook = OracleHook(oracle_conn_id=self.oracle_conn_id)
-        return hook.callproc(self.procedure, autocommit=True, parameters=self.parameters)
+        ti=context.get('task_instance')
+        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)
+            ti.xcom_push(key='ORA', value=str(code.split('-')[1]))
+            raise AirflowException(f"Task failed with exit code: {code}")

Review Comment:
   @uranusjr  applied. Also removed import. thanks.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org