Skip to content

Commit

Permalink
Merge #3880 Correctly print cmdline errors with braces
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Aug 15, 2023
2 parents 7260d2a + 11c0589 commit 9d0b75e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
- [Core] Add missing resource string for upgrading (#3873 by: HebaruSan; reviewed: techman83)
- [Multiple] Repository management fixes (#3876 by: HebaruSan; reviewed: techman83)
- [GUI] Restore window position without default instance (#3878 by: HebaruSan; reviewed: techman83)
- [CLI] Correctly print cmdline errors with braces (#3880 by: HebaruSan; reviewed: techman83)

### Internal

Expand Down
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

0 comments on commit 9d0b75e

Please sign in to comment.