Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Print inner startup exception cause to stderr
Browse files Browse the repository at this point in the history
Startup exceptions should have the cause printed to the stderr. Currently the full stack trace is printed to the log file, and only startup exception to the stderr - looking like this

  Exception in thread "main" com.google.enterprise.adaptor.StartupException: Failed to start application.
    at com.google.enterprise.adaptor.Application.main(Application.java:555)
    at com.google.enterprise.adaptor.AbstractAdaptor.main(AbstractAdaptor.java:61)
    at com.google.enterprise.adaptor.database.DatabaseAdaptor.main(DatabaseAdaptor.java:271)

Especially when there are some other warnings printed out to stdout/stderr, this can be confusing, so including also the inner exception in the message
  • Loading branch information
ondrejnovak committed Oct 12, 2015
1 parent 9fcf3fd commit 0ec3148
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/com/google/enterprise/adaptor/Application.java
Expand Up @@ -555,13 +555,16 @@ public static Application main(Adaptor adaptor, String[] args) {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.log(Level.INFO, "Application startup interrupted.", e);
throw new StartupException("Application startup interrupted.");
throw new StartupException(
"Application startup interrupted. " + e.toString());
} catch (IOException e) {
log.log(Level.SEVERE, "Failed to start application.", e);
throw new StartupException("Failed to start application.");
throw new StartupException(
"Failed to start application. " + e.toString());
} catch (RuntimeException e) {
log.log(Level.SEVERE, "Failed to start application.", e);
throw new StartupException("Failed to start application.");
throw new StartupException(
"Failed to start application. " + e.toString());
}
}

Expand Down

0 comments on commit 0ec3148

Please sign in to comment.