Skip to content

Commit

Permalink
Merge pull request #475 from npetzall/print_exception_message
Browse files Browse the repository at this point in the history
Log Exception.getMessage() but not stacktrace.
  • Loading branch information
npetzall committed Dec 7, 2018
2 parents 6cd278c + 4a00dcc commit 1f42118
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 64 deletions.
15 changes: 8 additions & 7 deletions src/main/java/org/schemaspy/cli/SchemaSpyRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.schemaspy.model.ConnectionFailure;
import org.schemaspy.model.EmptySchemaException;
import org.schemaspy.model.InvalidConfigurationException;
import org.schemaspy.model.ProcessExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -33,7 +32,9 @@
import org.springframework.boot.logging.LoggingSystem;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.sql.SQLException;
import java.util.Arrays;

@Component
Expand Down Expand Up @@ -105,14 +106,14 @@ private void runAnalyzer(String... args) {
exitCode = EXIT_CODE_CONFIG_ERROR;
LOGGER.debug("Command line parameters: {}", Arrays.asList(args));
if (badConfig.getParamName() != null) {
LOGGER.error("Bad parameter: '{} = {}' , {}", badConfig.getParamName(), badConfig.getParamValue(), badConfig.getMessage(), badConfig);
LOGGER.error("Bad parameter: '{} = {}'", badConfig.getParamName(), badConfig.getParamValue(), badConfig);
} else {
LOGGER.error("Bad config: {}", badConfig.getMessage(), badConfig);
LOGGER.error("Bad config", badConfig);
}
} catch (ProcessExecutionException badLaunch) {
LOGGER.warn(badLaunch.getMessage(), badLaunch);
} catch (Exception exc) {
LOGGER.error(exc.getMessage(), exc);
} catch (SQLException e) {
LOGGER.error("SqlException", e);
} catch (IOException e) {
LOGGER.error("IOException", e);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/schemaspy/logging/StackTraceOmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.context.ApplicationListener;

import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;

/**
Expand All @@ -51,6 +52,9 @@ public String convert(ILoggingEvent event) {
if (SCHEMA_SPY_LOGGER.isDebugEnabled())
return super.convert(event);
omittedStackTrace.set(true);
if (Objects.nonNull(event.getThrowableProxy())) {
return event.getThrowableProxy().getMessage() + CoreConstants.LINE_SEPARATOR;
}
return CoreConstants.EMPTY_STRING;
}

Expand Down
57 changes: 0 additions & 57 deletions src/main/java/org/schemaspy/model/ProcessExecutionException.java

This file was deleted.

0 comments on commit 1f42118

Please sign in to comment.