Catch exceptions thrown by filesystem calls, and don't really
            execute them in dry-run mode.
338411
def guarded(self, call, *args):
        
        self.LOG.debug('%s(%s)' % (
            call.__name__, ', '.join([pretty_path(i) for i in args]),
        ))
        if not self.options.dry_run:
            try:
                call(*args)
            except (EnvironmentError, UnicodeError) as exc:
                self.fatal('%s(%s) failed [%s]' % (
                    call.__name__, ', '.join([pretty_path(i) for i in args]), exc,
                ))
112420
def should_ignore(self, filename):
        """"""
        _, ext = os.path.splitext(filename)
        return ext in self.ignored_file_extensions
1287531
private static void throwCause(final ExecutionException ex) {
        if (ex.getCause() instanceof RuntimeException) {
            throw (RuntimeException) ex.getCause();
        }

        if (ex.getCause() instanceof Error) {
            throw (Error) ex.getCause();
        }
    }
627571
private void handleIOException(IOException e, String action, int attempt)
            throws VoldemortException, InterruptedException {
        if ( // any of the following happens, we need to bubble up
                // FileSystem instance got closed, somehow
                e.getMessage().contains("Filesystem closed") ||
                // HDFS permission issues
                ExceptionUtils.recursiveClassEquals(e, AccessControlException.class)) {
            throw new VoldemortException("Got an IOException we cannot recover from while trying to " +
                    action + ". Attempt # " + attempt + "/" + maxAttempts + ". Will not try again.", e);
        } else {
            logFailureAndWait(action, IO_EXCEPTION, attempt, e);
        }
    }
337674
def clean_fail(func):
    '''
    
    '''
    def func_wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except botocore.exceptions.ClientError as e:
            print(str(e), file=sys.stderr)
            sys.exit(1)
    return func_wrapper
374619
def _handle_run_exception(self, exc):
        
        if len(self._current_tups) == 1:
            tup = self._current_tups[0]
            self.raise_exception(exc, tup)
            if self.auto_fail:
                self.fail(tup)
794975
def _catch_exceptions(self, exctype, value, tb):
        """"""

        # Now we log it.
        self.error('Uncaught exception', exc_info=(exctype, value, tb))

        # First, we print to stdout with some colouring.
        print_exception_formatted(exctype, value, tb)
1233202
def try_catch(func, *args, **kwargs):
    '''
    
    '''
    try:
        return log_debug(func, *args, **kwargs)
    except Exception as exc:
        logging.debug('Error in "%s" in thread %s: %s', func.__name__, current_thread(), exc)
        return exc
149536
def exception_handler(self, pdb):
        '''
        

        '''

        # Grab the exception
        exctype, value, tb = sys.exc_info()

        # Log the error and create a .err file
        errfile = os.path.join(self.dir, self.name + '.err')
        with open(errfile, 'w') as f:
            for line in traceback.format_exception_only(exctype, value):
                ln = line.replace('\n', '')
                log.error(ln)
                print(ln, file=f)
            for line in traceback.format_tb(tb):
                ln = line.replace('\n', '')
                log.error(ln)
                print(ln, file=f)

        # Re-raise?
        if pdb:
            raise
330940
public void executeAndWait() throws Exception
    {
        Process p = launchProcess();
        checkForErrors(p);

		if (log.isDebugEnabled())
		{
			// GP-551 : Keep trace of outputs
			if (isNotBlank(getOutput()))
			{
				log.debug("System Output during execution : \n" + getOutput());
			}
			
			if (gobbler.hasErrors())
			{
				log.debug("System Error Output during execution : \n" + getError());
			}
		}
    }
1356561
void handleFailure(IOException ex, int failures)
      throws IOException {
    // Check if the exception was thrown by the network stack
    if (failoverClient.isShuttingdown() || !shouldHandleException(ex)) {
      throw ex;
    }
    if (failures > FAILURE_RETRY) {
      throw ex;
    }
    try {
      // This might've happened because we are failing over
      if (!watchZK) {
        LOG.debug("Not watching ZK, so checking explicitly");
        // Check with zookeeper
        fsLock.readLock().unlock();
        InjectionHandler.processEvent(InjectionEvent.DAFS_CHECK_FAILOVER);
        fsLock.writeLock().lock();
        boolean failover = false;
        try {
          failover = zkCheckFailover(ex);
        } finally {
          fsLock.writeLock().unlock();
          fsLock.readLock().lock();
        }
        if (failover) {
          return;
        }
      }
      Thread.sleep(1000);
    } catch (InterruptedException iex) {
      LOG.error("Interrupted while waiting for a failover", iex);
      Thread.currentThread().interrupt();
    }
  }
783870
def fire_exception(exc, opts, job=None, node='minion'):
    '''
    
    '''
    if job is None:
        job = {}
    event = salt.utils.event.SaltEvent(node, opts=opts, listen=False)
    event.fire_event(pack_exception(exc), '_salt_error')
174624
protected void throwIfError() throws IOException {
        if (_err != null) {
            _err.addSuppressed(new Throwable());
            if (_err instanceof IOException)
                throw (IOException) _err;
            if (_err instanceof IllegalStateException)
                throw (IllegalStateException) _err;
            throw new IllegalStateException(_err);
        }
    }
1220783
private static void _invokeCustomExceptionCallback (@Nonnull final Throwable ex)
  {
    s_aExceptionCallbacks.forEach (x -> x.onException (ex));
  }
1273640
static IOException getCauseIfDiskError(IOException ioe) {
    if (ioe.getMessage()!=null && ioe.getMessage().startsWith(DISK_ERROR)) {
      return (IOException)ioe.getCause();
    } else {
      return null;
    }
  }
778701
def _run_lint_on_file_exceptions(file_path,
                                 linter_functions,
                                 tool_options,
                                 fix_what_you_can):
    
    try:
        return _run_lint_on_file(file_path,
                                 linter_functions,
                                 tool_options,
                                 fix_what_you_can)
    except Exception as exception:
        sys.stderr.write("""Encountered exception when processing {}\n""".format(file_path))
        traceback.print_exc()
        raise exception
1245306
private void blockIfNecessary() {
        if (diskPermits == null || diskLimit == Long.MAX_VALUE)
            return;
        try {
            diskPermits.acquire();
        } catch (InterruptedException e) {
            // don't want to re-interrupt so it won't cause SDK stream to be
            // closed in case the thread is reused for a different request
            throw new AbortedException(e);
        }
    }