如何捕获io.dropwizard.configuration.ConfigurationParsingException
,以便可以正确记录?
以某种方式绕过所有捕获块
public class App extends Application<AppConfig> {
private static final Logger LOG = LoggerFactory.getLogger(App.class);
@Override
public void run(final AppConfig config, final Environment environment) {
try {
environment.jersey().register(new StatusResource());
LOG.info("start-up");
} catch (final Exception e) {
LOG.error("start-up failed: {}", e.getMessage(), e);
}
}
public static void main(String[] args) throws Exception {
try {
new App().run(args);
} catch (final Exception e) {
LOG.error("failed to create foo: {}", e.getMessage(), e);
}
}
}
查看DropWizard的文档,您所调用的方法都不会引发任何异常。我敢说您调用的方法之一是处理抛出的错误,因此它不会向上传播到catch块。希望这会有所帮助。