Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too much information in error. #1393

Open
npetzall opened this issue Jan 16, 2024 · 0 comments
Open

Too much information in error. #1393

npetzall opened this issue Jan 16, 2024 · 0 comments

Comments

@npetzall
Copy link
Member

When trying to connect with a faulty driver path, the logged error is confusing by providing too much data.

WARN  - Provided -dp(driverPath) '/Users/****/.m2/repository/com/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28.jar' doesn't exist
WARN  - Connection Failure
Failed to connect to database URL [jdbc:mysql://localhost:43057/htmlit] Failed to create driver from driver class. Failed to create any of 'com.mysql.cj.jdbc.Driver, com.mysql.jdbc.Driver' driver from driver path.

We might have grouped too much into the "Connection Failure" category. Since the connection string isn't important.
I think we wrap three different exceptions which is probably unnecessary due to the fact that anything that is related to Connection (actually, connecting) or creating a driver is fatal/unrecoverable. Needs user intervention.

So the assumption would be that it shouldn't be caught either bubble all the way out of the application or it should be caught in SchemaSpyRunner to manage exit code.

WARN  - Connection Failure
org.schemaspy.input.dbms.exceptions.ConnectionFailure: Failed to connect to database URL [jdbc:mysql://localhost:43057/htmlit] Failed to create driver from driver class. Failed to create any of 'com.mysql.cj.jdbc.Driver, com.mysql.jdbc.Driver' driver from driver path.
	at org.schemaspy.connection.ScExceptionChecked.connection(ScExceptionChecked.java:26)
	at org.schemaspy.input.dbms.service.SqlService.connect(SqlService.java:74)
	at org.schemaspy.SchemaAnalyzer.analyze(SchemaAnalyzer.java:275)
	at org.schemaspy.SchemaAnalyzer.analyze(SchemaAnalyzer.java:159)
	at org.schemaspy.cli.SchemaSpyRunner.run(SchemaSpyRunner.java:66)
	at org.schemaspy.Main.run(Main.java:145)
	at org.schemaspy.Main.main(Main.java:89)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:95)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: org.schemaspy.input.dbms.exceptions.ConnectionFailure: Failed to create driver from driver class. Failed to create any of 'com.mysql.cj.jdbc.Driver, com.mysql.jdbc.Driver' driver from driver path.
	at org.schemaspy.input.dbms.driver.DsDriverClass.driver(DsDriverClass.java:25)
	at org.schemaspy.input.dbms.driver.DsCached.driver(DsCached.java:24)
	at org.schemaspy.input.dbms.DbDriverLoader.driver(DbDriverLoader.java:76)
	at org.schemaspy.input.dbms.DriverFromConfig.driver(DriverFromConfig.java:23)
	at org.schemaspy.connection.ScSimple.connection(ScSimple.java:50)
	at org.schemaspy.connection.ScNullChecked.connection(ScNullChecked.java:21)
	at org.schemaspy.connection.ScExceptionChecked.connection(ScExceptionChecked.java:23)
	... 14 common frames omitted
Caused by: org.schemaspy.input.dbms.exceptions.ConnectionFailure: Failed to create any of 'com.mysql.cj.jdbc.Driver, com.mysql.jdbc.Driver' driver from driver path.
	at org.schemaspy.input.dbms.driverclass.DcFacade.value(DcFacade.java:44)
	at org.schemaspy.input.dbms.driver.DsDriverClass.driver(DsDriverClass.java:23)
	... 20 common frames omitted

Solutions to to be discussed would be

  1. Don't catch exception, it's too broad.
  2. Check if ConnectionFailure and re-throw it instead of wrapping.

As a side-note, ConnectionFailure should probably be logged as ERROR and not WARN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant