Skip to content

Commit

Permalink
[dotnet-linker] Improve the error message from the linker when we run…
Browse files Browse the repository at this point in the history
… into a problem. (xamarin#14253)

* Better text.
* Better number ("7000" is more like "this is kind of normal" - while "6999"
  was more like "something quite expected happened").
* Use resources to make it localizable.
  • Loading branch information
rolfbjarne authored and TJ Lambert committed Mar 8, 2022
1 parent 48a00ce commit c93966e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions tools/dotnet-linker/LinkerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,9 @@ public static void Report (LinkContext context, IList<Exception> exceptions)
var list = ErrorHelper.CollectExceptions (exceptions);
var allWarnings = list.All (v => v is ProductException pe && !pe.Error);
if (!allWarnings) {
// Revisit the error code after https://github.com/mono/linker/issues/1596 has been fixed.
var instance = GetInstance (context, false);
var platform = (instance?.Platform)?.ToString () ?? "unknown";
var msg = MessageContainer.CreateCustomErrorMessage ("Failed to execute the custom steps.", 6999, platform);
var msg = MessageContainer.CreateCustomErrorMessage (Errors.MX7000 /* An error occured while executing the custom linker steps. Please review the build log for more information. */, 7000, platform);
context.LogMessage (msg);
}
// ErrorHelper.Show will print our errors and warnings to stderr.
Expand Down
9 changes: 9 additions & 0 deletions tools/mtouch/Errors.designer.cs

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

7 changes: 7 additions & 0 deletions tools/mtouch/Errors.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,13 @@
</value>
</data>

<!-- The linker says custom linker steps can't use error codes between 1000 and 6000, so we use >= 7000 -->
<data name="MX7000" xml:space="preserve">
<value>An error occured while executing the custom linker steps. Please review the build log for more information.</value>
</data>

<!-- 8XXX are for errors that occur at runtime -->

<data name="MT8018" xml:space="preserve">
<value>Internal consistency error. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new.
</value>
Expand Down

0 comments on commit c93966e

Please sign in to comment.