private HadoopException analyzeFlow(final String execUrl) throws AuthenticationException, IOException {
    HadoopSecurity _hadoopSecurity = HadoopSecurity.getInstance();

    return _hadoopSecurity.doAs(new PrivilegedAction<HadoopException>() {
      @Override
      public HadoopException run() {
        HadoopException flowLevelException = new HadoopException();
        List<HadoopException> childExceptions = new ArrayList<HadoopException>();
        Map<String, String> jobIdStatus = _workflowClient.getJobsFromFlow();

        // Find exceptions in all the unsuccessful jobs of the workflow
        for (String unsuccessfulJobId : jobIdStatus.keySet()) {
          if (jobIdStatus.get(unsuccessfulJobId).toLowerCase().equals("failed")) {
            HadoopException jobLevelException = analyzeJob(unsuccessfulJobId);
            childExceptions.add(jobLevelException);
          }
        }

        flowLevelException.setType(HadoopException.HadoopExceptionType.FLOW);
        flowLevelException.setId(execUrl);
        flowLevelException.setLoggingEvent(null); // No flow level exception
        flowLevelException.setChildExceptions(childExceptions);
        return flowLevelException;
      }
    });
 }
Analyzes a Flow and returns a HadoopException object which captures all the exception in the flow.
@param execUrl the execution URL of the flow
@return HadoopException object which captures all the exceptions in the given Flow
app/com/linkedin/drelephant/exceptions/ExceptionFinder.java