io.dropwizard.Application.onFatalError()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(77)

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

Application.onFatalError介绍

[英]Called by #run(String...) to indicate there was a fatal error running the requested command. The default implementation calls System#exit(int) with a non-zero status code to terminate the application.
[中]由#run(字符串…)调用指示运行请求的命令时出现致命错误。默认实现使用非零状态代码调用System#exit(int)来终止应用程序。

代码示例

代码示例来源:origin: dropwizard/dropwizard

/**
 * Parses command-line arguments and runs the application. Call this method from a {@code public
 * static void main} entry point in your application.
 *
 * @param arguments the command-line arguments
 * @throws Exception if something goes wrong
 */
public void run(String... arguments) throws Exception {
  final Bootstrap<T> bootstrap = new Bootstrap<>(this);
  addDefaultCommands(bootstrap);
  initialize(bootstrap);
  // Should be called after initialize to give an opportunity to set a custom metric registry
  bootstrap.registerMetrics();
  final Cli cli = new Cli(new JarLocation(getClass()), bootstrap, System.out, System.err);
  if (!cli.run(arguments)) {
    // only exit if there's an error running the command
    onFatalError();
  }
}

代码示例来源:origin: io.dropwizard/dropwizard-core

/**
 * Parses command-line arguments and runs the application. Call this method from a {@code public
 * static void main} entry point in your application.
 *
 * @param arguments the command-line arguments
 * @throws Exception if something goes wrong
 */
public void run(String... arguments) throws Exception {
  final Bootstrap<T> bootstrap = new Bootstrap<>(this);
  addDefaultCommands(bootstrap);
  initialize(bootstrap);
  // Should be called after initialize to give an opportunity to set a custom metric registry
  bootstrap.registerMetrics();
  final Cli cli = new Cli(new JarLocation(getClass()), bootstrap, System.out, System.err);
  if (!cli.run(arguments)) {
    // only exit if there's an error running the command
    onFatalError();
  }
}

代码示例来源:origin: org.sonatype.goodies.dropwizard/dropwizard-support-core

/**
 * Invoked on fatal error before shutdown.
 */
@Override
protected void onFatalError() {
 log.error("Fatal error detected; shutting down");
 super.onFatalError();
}

相关文章