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

Improve connection string parsing failure exception #763

Closed
bgrainger opened this issue Jan 15, 2020 · 2 comments
Closed

Improve connection string parsing failure exception #763

bgrainger opened this issue Jan 15, 2020 · 2 comments

Comments

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Jan 15, 2020

At https://stackoverflow.com/questions/59755394/add-record-to-mysql-always-raises-input-string-was-not-in-a-correct-format-er a user posts this exception from having a malformed connection string:

System.FormatException
           at System.Number.StringToNumber(ReadOnlySpan`1 str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
           at System.Number.ParseUInt32(ReadOnlySpan`1 value, NumberStyles options, NumberFormatInfo numfmt)
           at System.String.System.IConvertible.ToUInt32(IFormatProvider provider)
           at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
           at MySql.Data.MySqlClient.MySqlConnectionStringValueOption`1.ChangeType(Object objectValue) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnectionStringBuilder.cs:line 703
           at MySql.Data.MySqlClient.MySqlConnectionStringValueOption`1.GetValue(MySqlConnectionStringBuilder builder) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnectionStringBuilder.cs:line 674
           at MySqlConnector.Core.ConnectionSettings..ctor(MySqlConnectionStringBuilder csb) in C:\projects\mysqlconnector\src\MySqlConnector\Core\ConnectionSettings.cs:line 39
           at MySqlConnector.Core.ConnectionPool.GetPool(String connectionString) in C:\projects\mysqlconnector\src\MySqlConnector\Core\ConnectionPool.cs:line 405
           at MySql.Data.MySqlClient.MySqlConnection.OpenAsync(Nullable`1 ioBehavior, CancellationToken cancellationToken) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnection.cs:line 292
           at MySql.Data.MySqlClient.MySqlConnection.Open() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnection.cs:line 280
           at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
           at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
           at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlRelationalConnection.Open(Boolean errorsExpected)
           at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel)
           at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction()
           at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
           at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries)
           at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
           at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess)
           at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
           at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
           at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
           at Microsoft.EntityFrameworkCore.DbContext.SaveChanges()

This is not an easy exception message or call stack to understand. It would be better to have a message such as "{x} is not a valid value for the {y} connection string option".

@bgrainger
Copy link
Member Author

@bgrainger bgrainger commented Jan 22, 2020

Connector/NET throws an ArgumentException: "Value 'pants' is not of the correct type."

@bgrainger
Copy link
Member Author

@bgrainger bgrainger commented Mar 7, 2020

Improved in 0.62.0.

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

No branches or pull requests

1 participant