Propagate the cause when failing to parse a connection string

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Diagnostics
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If I set an incorrect connection string, I get an error like this:

      Caused by: java.lang.RuntimeException: Failed to get com.mongodb.ConnectionString from configuration property [jakarta.persistence.jdbc.url] with value [mongodb+srv://mongo:27017/mongo]
          at com.mongodb.hibernate.internal.cfg.MongoConfigurationBuilder$ConfigPropertiesParser$Exceptions.failedToParse(MongoConfigurationBuilder.java:105)
          at com.mongodb.hibernate.internal.cfg.MongoConfigurationBuilder$ConfigPropertiesParser.parseConnectionString(MongoConfigurationBuilder.java:89)
       

      It doesn't show the cause, which makes it harder to debug.

      The code that fails to propagate the code is in `MongoConfigurationBuilder`:

      private static ConnectionString parseConnectionString(String propertyName, String propertyValue) {
          try {
              return new ConnectionString(propertyValue);
          } catch (RuntimeException e) {
              throw MongoConfigurationBuilder.ConfigPropertiesParser.Exceptions.failedToParse(
                      propertyName, propertyValue, ConnectionString.class);
          }
      }
       

       

            Assignee:
            Almas Abdrazak
            Reporter:
            Yoann Rodière
            Valentin Kavalenka
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: