Issue #722: Tweak TMySQLConnection.GetLastErrorMsg so it shows an additional more helpful message what the user could do to solve his SSL connection error

This commit is contained in:
Ansgar Becker
2019-07-23 22:00:12 +02:00
parent ae95c2f14a
commit 4b84ffa7ef
2 changed files with 24 additions and 9 deletions

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2019-07-14 19:44+0200\n"
"PO-Revision-Date: 2019-07-23 21:57+0200\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"MIME-Version: 1.0\n"
@@ -4764,6 +4764,10 @@ msgstr "Uptime"
msgid "unknown"
msgstr "unknown"
#. Give the user some hint what he can do with his SSL related connection error
msgid "Please select a different library in your session settings. (Current: \"%s\")"
msgstr "Please select a different library in your session settings. (Current: \"%s\")"
#: main.pas:5261
msgid "Specify filter-value..."
msgstr "Specify filter-value..."

View File

@@ -3289,16 +3289,27 @@ var
rx: TRegExpr;
begin
Result := '';
Additional := '';
Msg := DecodeAPIString(FLib.mysql_error(FHandle));
// Find "(errno: 123)" in message and add more meaningful message from perror.exe
rx := TRegExpr.Create;
rx.Expression := '.+\(errno\:\s+(\d+)\)';
if rx.Exec(Msg) then begin
Additional := MySQLErrorCodes.Values[rx.Match[1]];
if Additional <> '' then
Msg := Msg + CRLF + CRLF + Additional;
if SynRegExpr.ExecRegExpr('(Unknown SSL error|SSL connection error)', Msg) then begin
// Find specific strings in error message and provide helpful message
Additional := f_('Please select a different library in your session settings. (Current: "%s")', [FParameters.LibraryFile]);
end else begin
// Find "(errno: 123)" in message and add more meaningful message from perror.exe
rx := TRegExpr.Create;
rx.Expression := '.+\(errno\:\s+(\d+)\)';
if rx.Exec(Msg) then begin
Additional := MySQLErrorCodes.Values[rx.Match[1]];
end;
rx.Free;
end;
rx.Free;
if Additional <> '' then begin
Msg := Msg + sLineBreak + sLineBreak + Additional;
end;
case FStatementNum of
0: Result := Msg;
1: Result := f_(MsgSQLError, [LastErrorCode, Msg]);