jason810496 commented on code in PR #48466:
URL: https://github.com/apache/airflow/pull/48466#discussion_r2106064185


##########
providers/dbt/cloud/src/airflow/providers/dbt/cloud/operators/dbt.py:
##########
@@ -254,9 +265,21 @@ def execute_complete(self, context: Context, event: 
dict[str, Any]) -> int:
         """Execute when the trigger fires - returns immediately."""
         self.run_id = event["run_id"]
         if event["status"] == "cancelled":
-            raise DbtCloudJobRunException(f"Job run {self.run_id} has been 
cancelled.")
+
+            raise DbtCloudJobRunDetailsException(
+                self.account_id,
+                self.run_id,
+                message=f"Job run {self.run_id} has failed or has been 
cancelled.",

Review Comment:
   Should the message here just be `cancelled` ?



##########
providers/dbt/cloud/src/airflow/providers/dbt/cloud/operators/dbt.py:
##########
@@ -254,9 +265,21 @@ def execute_complete(self, context: Context, event: 
dict[str, Any]) -> int:
         """Execute when the trigger fires - returns immediately."""
         self.run_id = event["run_id"]
         if event["status"] == "cancelled":
-            raise DbtCloudJobRunException(f"Job run {self.run_id} has been 
cancelled.")
+
+            raise DbtCloudJobRunDetailsException(
+                self.account_id,
+                self.run_id,
+                message=f"Job run {self.run_id} has failed or has been 
cancelled.",
+            )
+
         elif event["status"] == "error":
-            raise DbtCloudJobRunException(f"Job run {self.run_id} has failed.")
+
+            raise DbtCloudJobRunDetailsException(
+                self.account_id,
+                self.run_id,
+                message=f"Job run {self.run_id} has failed or has been 
cancelled.",

Review Comment:
   ```suggestion
                   message=f"Job run {self.run_id} has failed",
   ```



##########
providers/dbt/cloud/src/airflow/providers/dbt/cloud/operators/dbt.py:
##########
@@ -239,7 +244,13 @@ def execute(self, context: Context):
                     DbtCloudJobRunStatus.CANCELLED.value,
                     DbtCloudJobRunStatus.ERROR.value,
                 ):
-                    raise DbtCloudJobRunException(f"Job run {self.run_id} has 
failed or has been cancelled.")
+
+                    raise DbtCloudJobRunDetailsException(
+                        self.account_id,
+                        self.run_id,
+                        message=f"Job run {self.run_id} has failed or has been 
cancelled.",

Review Comment:
   How about 
   ```suggestion
                           message=f"Job run was {job_run_status}",
   ```
   
   will this be more verbose for users ?



##########
providers/dbt/cloud/src/airflow/providers/dbt/cloud/utils/exceptions.py:
##########
@@ -0,0 +1,92 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import json
+
+from airflow.exceptions import AirflowException
+
+from airflow.providers.dbt.cloud.hooks.dbt import DbtCloudHook
+
+
+class DbtCloudJobRunDetailsException(AirflowException):
+    """
+    An exception that indicates a job run failed to complete.
+
+    Can provide additional job run details.
+    """
+
+    def __init__(
+        self,
+        account_id: int,
+        run_id: int,
+        message: str = "The job run has failed.",
+        # For extracting only a subset of the higher level job details
+        # id is the run_id
+        run_data_keys: dict = [

Review Comment:
   I think `mypy` will not happy with the type annotation, the default value is 
`list` instead of `dict`.



-- 
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