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

Correctly print cmdline errors with braces #3880

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cmdline/Action/AuthToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private int addAuthToken(AddAuthTokenOptions opts)
}
else
{
user.RaiseError("Invalid host name: {0}", opts.host);
user.RaiseError(Properties.Resources.AuthTokenInvalidHostName, opts.host);
}
return Exit.OK;
}
Expand Down
6 changes: 3 additions & 3 deletions Cmdline/Action/GameInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -637,21 +637,21 @@ int badArgument()
catch (BadInstallLocationKraken kraken)
{
// The folder exists and is not empty.
User.RaiseError(kraken.Message);
User.RaiseError("{0}", kraken.Message);
return badArgument();
}
catch (WrongGameVersionKraken kraken)
{
// Thrown because the specified game instance is too old for one of the selected DLCs.
User.RaiseError(kraken.Message);
User.RaiseError("{0}", kraken.Message);
return badArgument();
}
catch (NotKSPDirKraken kraken)
{
// Something went wrong adding the new instance to the registry,
// most likely because the newly created directory is somehow not valid.
log.Error(kraken);
User.RaiseError(kraken.Message);
User.RaiseError("{0}", kraken.Message);
return error();
}
catch (InvalidKSPInstanceKraken)
Expand Down
19 changes: 10 additions & 9 deletions Cmdline/Action/Install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ public int RunCommand(CKAN.GameInstance instance, object raw_options)
}
catch (Kraken kraken)
{
user.RaiseError(kraken.InnerException == null
? kraken.Message
: $"{kraken.Message}: {kraken.InnerException.Message}");
user.RaiseError("{0}",
kraken.InnerException == null
? kraken.Message
: $"{kraken.Message}: {kraken.InnerException.Message}");
}
}

Expand Down Expand Up @@ -142,7 +143,7 @@ public int RunCommand(CKAN.GameInstance instance, object raw_options)
}
catch (DependencyNotSatisfiedKraken ex)
{
user.RaiseError(ex.Message);
user.RaiseError("{0}", ex.Message);
user.RaiseMessage(Properties.Resources.InstallTryAgain);
return Exit.ERROR;
}
Expand Down Expand Up @@ -214,7 +215,7 @@ public int RunCommand(CKAN.GameInstance instance, object raw_options)
catch (InconsistentKraken ex)
{
// The prettiest Kraken formats itself for us.
user.RaiseError(ex.InconsistenciesPretty);
user.RaiseError("{0}", ex.InconsistenciesPretty);
user.RaiseMessage(Properties.Resources.InstallCancelled);
return Exit.ERROR;
}
Expand All @@ -226,12 +227,12 @@ public int RunCommand(CKAN.GameInstance instance, object raw_options)
catch (MissingCertificateKraken kraken)
{
// Another very pretty kraken.
user.RaiseError(kraken.ToString());
user.RaiseError("{0}", kraken.ToString());
return Exit.ERROR;
}
catch (DownloadThrottledKraken kraken)
{
user.RaiseError(kraken.ToString());
user.RaiseError("{0}", kraken.ToString());
user.RaiseMessage(Properties.Resources.InstallTryAuthToken, kraken.infoUrl);
return Exit.ERROR;
}
Expand All @@ -242,12 +243,12 @@ public int RunCommand(CKAN.GameInstance instance, object raw_options)
}
catch (ModuleDownloadErrorsKraken kraken)
{
user.RaiseError(kraken.ToString());
user.RaiseError("{0}", kraken.ToString());
return Exit.ERROR;
}
catch (DirectoryNotFoundKraken kraken)
{
user.RaiseError(kraken.Message);
user.RaiseError("{0}", kraken.Message);
return Exit.ERROR;
}
catch (ModuleIsDLCKraken kraken)
Expand Down
2 changes: 1 addition & 1 deletion Cmdline/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private static int Scan(CKAN.GameInstance inst, IUser user, string next_command

if (next_command == null)
{
user.RaiseError(kraken.InconsistenciesPretty);
user.RaiseError("{0}", kraken.InconsistenciesPretty);
user.RaiseError(Properties.Resources.ScanNotSaved);
}
else
Expand Down
3 changes: 3 additions & 0 deletions Cmdline/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cmdline/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Update recommended!</value></data>
<data name="AuthTokenHostHeader" xml:space="preserve"><value>Host</value></data>
<data name="AuthTokenTokenHeader" xml:space="preserve"><value>Token</value></data>
<data name="AuthTokenHelpSummary" xml:space="preserve"><value>Manage authentication tokens</value></data>
<data name="AuthTokenInvalidHostName" xml:space="preserve"><value>Invalid host name: {0}</value></data>
<data name="AvailableHeader" xml:space="preserve"><value>Modules compatible with {0} {1}</value></data>
<data name="CacheHelpSummary" xml:space="preserve"><value>Manage the download cache path of CKAN</value></data>
<data name="CacheSet" xml:space="preserve"><value>Download cache set to {0}</value></data>
Expand Down
Loading