Exception handling wrapper for Win32OLE exceptions.
 Catch/log Win32OLE exceptions, pass on all others...
435896
def try
      yield
    rescue WIN32OLERuntimeError => e
      puts :error, "Ignoring caught Win32ole runtime error:", e
      sleep 0.1 # Give other Threads a chance to execute
    rescue Exception => e
      self.finalize if respond_to? :finalize
      puts :error, "Raising non-Win32ole error:", e
      raise e
    end
1037632
def catch(ignore=[],
          was_doing="something important",
          helpfull_tips="you should use a debugger",
          gbc=None):
    
    exc_cls, exc, tb=sys.exc_info()
    if exc_cls in ignore:
        msg='exception in ignorelist'
        gbc.say('ignoring caught:'+str(exc_cls))
        return 'exception in ignorelist'
        

    ex_message = traceback.format_exception_only(exc_cls, exc)[-1]
    ex_message = ex_message.strip()
    
    # TODO: print(ex_message)

    error_frame = tb
    while error_frame.tb_next is not None:
        error_frame = error_frame.tb_next

    file = error_frame.tb_frame.f_code.co_filename
    line = error_frame.tb_lineno
    stack = traceback.extract_tb(tb)

    formated_stack = []
    for summary in stack:
        formated_stack.append({
            'file': summary[0],
            'line': summary[1],
            'func': summary[2],
            'text': summary[3]
        })

    event = {
        'was_doing':was_doing,
        'message': ex_message,
        'errorLocation': {
            'file': file,
            'line': line,
            'full': file + ' -> ' + str(line)
        },
        'stack': formated_stack
        #,
        #'time': time.time()
    }

    try:
        #logging.info('caught:'+pformat(event))
        gbc.cry('caught:'+pformat(event))
        print('Bubble3: written error to log')
        print('Bubble3: tips for fixing this:')
        print(helpfull_tips)

    except Exception as e:
        print('Bubble3: cant log error cause of %s' % e)
1371290
public static void displayIOException(@Nonnull IOException e, @Nonnull TaskListener listener ) {
        String msg = getWin32ErrorMessage(e);
        if(msg!=null)
            listener.getLogger().println(msg);
    }
90569
def _exception(etype, eval_, etrace):
        
        if hasattr(sys, 'ps1') or not sys.stderr.isatty():
            # we are in interactive mode or we don't have a tty-like
            # device, so we call the default hook
            sys.__excepthook__(etype, eval_, etrace)
        else:
            # we are NOT in interactive mode, print the exception...
            traceback.print_exception(etype, eval_, etrace, limit=2,
                                      file=sys.stdout)
            six.print_()
            # ...then start the debugger in post-mortem mode.
            pdb.pm()
24631
def exception(self, *args, **kwargs):
        """"""
        return self._log_kw(ERROR, args, kwargs, exc_info=True)
521119
def handleError(self, record):
        '''
        
        '''
        handled = False
        if sys.stderr and sys.version_info >= (3, 5, 4):
            t, v, tb = sys.exc_info()
            if t.__name__ in 'FileNotFoundError':
                sys.stderr.write('[WARNING ] The log_file does not exist. Logging not setup correctly or syslog service not started.\n')
                handled = True

        if not handled:
            super(SysLogHandler, self).handleError(record)
1275270
def _log_exception(self, exception):
        
        self._io.error(str(exception).strip().split(os.linesep))
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
473116
private void handleIOException(IOException e) {
    String content = e.getLocalizedMessage();
    if (e instanceof RemoteException) {
      int eol = content.indexOf('\n');
      if (eol>=0) {
        content = content.substring(0, eol);
      }      
    }
    System.err.println(getCommandName() + ": " + content);
  }
628359
def capture_exception(fn):
    """"""
    def wrapped(*args):
        try:
            return fn(*args)
        except Exception as e:
            return e
    return wrapped
712801
def handleException(self, exc_type, exc_param, exc_tb):
        ""
        self.writeline(''.join( traceback.format_exception(exc_type, exc_param, exc_tb) ))
        return True
447597
def exception_handler(self, ex):  # pylint: disable=no-self-use
        
        if isinstance(ex, CLIError):
            logger.error(ex)
        else:
            logger.exception(ex)
        return 1
619768
def ExceptionHook(exctype, value, tb):
    '''
    

    '''

    for line in traceback.format_exception_only(exctype, value):
        log.error(line.replace('\n', ''))
    for line in traceback.format_tb(tb):
        log.error(line.replace('\n', ''))
    sys.__excepthook__(exctype, value, tb)
682540
def exception_logger(exc_type, exc_value, exc_traceback):
    """"""
    if not issubclass(exc_type, KeyboardInterrupt):  # do not log Ctrl-C
        _log.critical(
            "Uncaught exception:",
            exc_info=(exc_type, exc_value, exc_traceback)
        )
    sys.__excepthook__(exc_type, exc_value, exc_traceback)
442283
public void handleExceptionRead(Exception e)
      {
        final String mName = "handleException";
        
        logger.finer("SKIPHANDLE: in skiphandler handle exception on a read");

        if(logger.isLoggable(Level.FINER)) 
          logger.logp(Level.FINE, className, mName, e.getClass().getName() + "; " + this.toString());
        
        if (!isSkipLimitReached() && excMatcher.isSkippableOrRetryable(e))
        {
          // Skip it.  Log it.  Call the SkipListener.
          ++_skipCount;
          logSkip(e);

          if (_skipReadListener != null) {
              for (SkipReadListenerProxy skipReadListenerProxy : _skipReadListener) {
                  skipReadListenerProxy.onSkipReadItem(e);
                }
          }
        }
        else
        {
          // No skip.  Throw it back. don't throw it back - we might want to retry ...
          if(logger.isLoggable(Level.FINER)) 
            logger.logp(Level.FINE, className, mName, "No skip.  Rethrow", e);
            throw new BatchContainerRuntimeException(e);
        }

        if(logger.isLoggable(Level.FINER)) 
          logger.exiting(className, mName, e);
      }
740660
def log_exception(exc_info=None, stream=None):
    """"""
    exc_info = exc_info or sys.exc_info()
    stream = stream or sys.stderr
    try:
        from traceback import print_exception
        print_exception(exc_info[0], exc_info[1], exc_info[2], None, stream)
        stream.flush()
    finally:
        exc_info = None
419117
async def on_error(self, event_method, *args, **kwargs):
        
        print('Ignoring exception in {}'.format(event_method), file=sys.stderr)
        traceback.print_exc()