java.util.logging.Handler.reportError()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中java.util.logging.Handler.reportError()方法的一些代码示例,展示了Handler.reportError()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handler.reportError()方法的具体详情如下:
包路径:java.util.logging.Handler
类名称:Handler
方法名:reportError

Handler.reportError介绍

[英]Reports an error to the error manager associated with this handler, ErrorManager is used for that purpose. No security checks are done, therefore this is compatible with environments where the caller is non-privileged.
[中]向与此处理程序关联的错误管理器报告错误,ErrorManager用于此目的。没有进行安全检查,因此这与调用者没有特权的环境兼容。

代码示例

代码示例来源:origin: com.microsoft.reef/reef-utils-hadoop

@Override
protected void reportError(final String s, final Exception e, final int i) {
 super.reportError(s, e, i);
}

代码示例来源:origin: javax.mail/com.springsource.javax.mail

/**
 * Protected convenience method to report an error to this Handler's
 * ErrorManager.  This method will prefix all non null error messages with
 * <tt>Level.SEVERE.getName()</tt>.  This allows the receiving error
 * manager to determine if the <tt>msg</tt> parameter is a simple error
 * message or a raw email message.
 * @param msg    a descriptive string (may be null)
 * @param ex     an exception (may be null)
 * @param code   an error code defined in ErrorManager
 */
protected void reportError(String msg, Exception ex, int code) {
  if (msg != null) {
    super.reportError(Level.SEVERE.getName() + ": " + msg, ex, code);
  } else {
    super.reportError(null, ex, code);
  }
}

代码示例来源:origin: stackoverflow.com

reportError(v, re, ErrorManager.OPEN_FAILURE);
  reportError("", e, ErrorManager.WRITE_FAILURE);

代码示例来源:origin: stackoverflow.com

out = new BufferedWriter(fstream);
} catch (IOException e) {
  reportError(e.getMessage(), e, ErrorManager.OPEN_FAILURE);
reportError(e.getMessage(), e, ErrorManager.WRITE_FAILURE);
reportError(e.getMessage(), e, ErrorManager.FLUSH_FAILURE);
  out.close();
} catch (IOException e) {
  reportError(e.getMessage(), e, ErrorManager.CLOSE_FAILURE);

代码示例来源:origin: stackoverflow.com

reportError(null, fnfe, ErrorManager.GENERIC_FAILURE);
fnfe.printStackTrace(System.err);

代码示例来源:origin: stackoverflow.com

Handler consoleHandler = new Handler(){
    @Override
     public void publish(LogRecord record)
     {
       if (getFormatter() == null)
       {
         setFormatter(new SimpleFormatter());
       }
       try {
         String message = getFormatter().format(record);
         if (record.getLevel().intValue() >= Level.WARNING.intValue())
         {
           System.err.write(message.getBytes());                       
         }
         else
         {
           System.out.write(message.getBytes());
         }
       } catch (Exception exception) {
         reportError(null, exception, ErrorManager.FORMAT_FAILURE);
       }
     }
     @Override
     public void close() throws SecurityException {}
     @Override
     public void flush(){}
   };

代码示例来源:origin: stackoverflow.com

init(record);
} catch (RuntimeException re) {
  reportError(null, re, ErrorManager.WRITE_FAILURE);
} catch (Exception e) {
  reportError(null, e, ErrorManager.WRITE_FAILURE);
    reportError(null, e, ErrorManager.WRITE_FAILURE);

代码示例来源:origin: stackoverflow.com

reportError(e.getMessage(), e, ErrorManager.FLUSH_FAILURE);
    outputStream.close();
  } catch (IOException e) {
    reportError(e.getMessage(), e, ErrorManager.CLOSE_FAILURE);
    reportError(e.getMessage(), e, ErrorManager.OPEN_FAILURE);
  reportError(e.getMessage(), e, ErrorManager.GENERIC_FAILURE);
  writer.close();         
} catch(Exception e) {
  reportError("Unable to rename old file: " + logFile.getName()
      + " to new file: " + newFile, null, ErrorManager.GENERIC_FAILURE);
  reportError(e.getMessage(), e, ErrorManager.OPEN_FAILURE);
} catch (IOException e) {
  reportError(e.getMessage(), e, ErrorManager.OPEN_FAILURE);
  reportError(e.getMessage(), e, ErrorManager.WRITE_FAILURE);

代码示例来源:origin: stackoverflow.com

this.reportError(null, jm, ErrorManager.WRITE_FAILURE);

代码示例来源:origin: javax.mail/com.springsource.javax.mail

/**
 * Converts a mime message to a raw string or formats the reason
 * why message can't be changed to raw string and reports it.
 * @param msg the mime message.
 * @param ex the original exception.
 * @param code the ErrorManager code.
 * @since JavaMail 1.4.5
 */
private void reportError(Message msg, Exception ex, int code) {
  try { //Use super call so we do not prefix raw email.
    super.reportError(toRawString(msg), ex, code);
  } catch (final MessagingException rawMe) {
    reportError(toMsgString(rawMe), ex, code);
  } catch (final IOException rawIo) {
    reportError(toMsgString(rawIo), ex, code);
  }
}

代码示例来源:origin: stackoverflow.com

this.reportError(null, jm, ErrorManager.WRITE_FAILURE);

代码示例来源:origin: stackoverflow.com

reportError(null, ex, ErrorManager.WRITE_FAILURE);
   mutex.close();
} catch (IOException ioe) {
  this.reportError(null, ioe, ErrorManager.CLOSE_FAILURE);

相关文章