2828import os
2929from collections .abc import Callable , Container , Sequence
3030from datetime import datetime
31- from subprocess import STDOUT , Popen
31+ from subprocess import STDOUT , Popen , SubprocessError
3232from time import sleep
3333from typing import TYPE_CHECKING , Any
3434
3535from airflow .models import BaseOperator
3636from airflow .models .dag import DAG
3737from airflow .models .variable import Variable
3838from airflow .providers .common .compat .sdk import (
39- AirflowException ,
4039 AirflowNotFoundException ,
4140 AirflowSkipException ,
4241)
@@ -125,7 +124,7 @@ class CmdOperator(BaseOperator):
125124 * - `skip_on_exit_code` (default: 99)
126125 - raise :class:`airflow.exceptions.AirflowSkipException`
127126 * - otherwise
128- - raise :class:`airflow.exceptions.AirflowException `
127+ - raise :class:`subprocess.SubprocessError `
129128
130129 .. warning::
131130
@@ -210,9 +209,9 @@ def get_env(self, context):
210209 def execute (self , context : Context ):
211210 if self .cwd is not None :
212211 if not os .path .exists (self .cwd ):
213- raise AirflowException (f"Can not find the cwd: { self .cwd } " )
212+ raise SubprocessError (f"Can not find the cwd: { self .cwd } " )
214213 if not os .path .isdir (self .cwd ):
215- raise AirflowException (f"The cwd { self .cwd } must be a directory" )
214+ raise SubprocessError (f"The cwd { self .cwd } must be a directory" )
216215 env = self .get_env (context )
217216
218217 # Because the command value is evaluated at runtime using the @task.command decorator, the
@@ -237,7 +236,7 @@ def execute(self, context: Context):
237236 if exit_code in self .skip_on_exit_code :
238237 raise AirflowSkipException (f"Command returned exit code { exit_code } . Skipping." )
239238 if exit_code != 0 :
240- raise AirflowException (f"Command failed. The command returned a non-zero exit code { exit_code } ." )
239+ raise SubprocessError (f"Command failed. The command returned a non-zero exit code { exit_code } ." )
241240
242241 return self .output_processor (outs )
243242
0 commit comments