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

[nnyeah] Centralize error handling #15064

Merged
merged 5 commits into from
May 23, 2022
Merged

Conversation

chamons
Copy link
Contributor

@chamons chamons commented May 19, 2022

- Due to microsoft/vstest#3658 it is not possible to test code that exits the process on error
- Create a base class for nnyeah exceptions that we want to explicitly report (and not crash), ConversionException
- Move Main to Main2 and wrap it in a try/catch for this exception
- I did not catch everything as for now I want to crash with stack trace on unexpected failures
@chamons chamons added skip-all-tests Skip all the tests not-notes-worthy Ignore for release notes labels May 19, 2022
Copy link
Member

@rolfbjarne rolfbjarne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more reason Environment.Exit is evil 👿

tools/nnyeah/nnyeah/Program.cs Outdated Show resolved Hide resolved
catch (ConversionException c) {
Console.Error.WriteLine (c.Message);
return 1;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to catch all exceptions too, otherwise the process will exit with a very ugly message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I wasn't sure here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add the following, do catch our base exception, then catch all exceptions and do a console.writeline with the message and then the url to provide an issue. If we got an unexpected exception it should be a bug/issue just like we do in xamarin.

Comment on lines +71 to +73
else {
ProcessAssembly (xamarinAssembly!, microsoftAssembly!, infile!, outfile!, verbose, forceOverwrite, suppressWarnings);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you changed this method to return the exit code, you won't need this change, you can just return 0; after PrintOptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that before. I felt that showing the flow as explicit "if show help do that, else do all of the processing" was better than an early return.

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's more of a style choice, either way is fine with me.

chamons and others added 2 commits May 19, 2022 11:09
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Comment on lines +71 to +73
else {
ProcessAssembly (xamarinAssembly!, microsoftAssembly!, infile!, outfile!, verbose, forceOverwrite, suppressWarnings);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's more of a style choice, either way is fine with me.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 Tests failed catastrophically on VSTS: simulator tests iOS (no summary found). 🔥

Result file D:\a\1\s\Reports\TestSummary-simulator\TestSummary.md not found.

Pipeline on Agent XAMBOT-1042.Monterey
Merge 2597435 into 1477c9b

@vs-mobiletools-engineering-service2

This comment has been minimized.

catch (ConversionException c) {
Console.Error.WriteLine (c.Message);
return 1;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add the following, do catch our base exception, then catch all exceptions and do a console.writeline with the message and then the url to provide an issue. If we got an unexpected exception it should be a bug/issue just like we do in xamarin.

@chamons
Copy link
Contributor Author

chamons commented May 20, 2022

I split uncaught exception and conversion exception, and print the full stack trace and a generic "file an issue" message for uncaught now:

Unexpected error - Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new
System.NotImplementedException: The method or operation is not implemented.
   at Microsoft.MaciOS.Nnyeah.Program.Main2(String[] args) in /Users/donblas/Programming/xamarin-macios/tools/nnyeah/nnyeah/Program.cs:line 62
   at Microsoft.MaciOS.Nnyeah.Program.Main(String[] args) in /Users/donblas/Programming/xamarin-macios/tools/nnyeah/nnyeah/Program.cs:line 24
donblas@Masterwork nnyeah % ~/bin/donut rung

vs

File for conversion (--input) and output location (--output) are required options.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Hash: 0b89a17580fa2c08c28be477b7922f9e3d3ea0b9

@vs-mobiletools-engineering-service2
Copy link
Collaborator

📚 [PR Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMBOT-1160.Monterey'
Hash: 0b89a17580fa2c08c28be477b7922f9e3d3ea0b9

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 Tests failed catastrophically on VSTS: simulator tests iOS (no summary found). 🔥

Result file D:\a\1\s\Reports\TestSummary-simulator\TestSummary.md not found.

Pipeline on Agent XAMBOT-1044.Monterey'
Merge 0b89a17 into b773b97

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Failed tests are:

  • xammac_tests
  • monotouch-test

Pipeline on Agent
Hash: 0b89a17580fa2c08c28be477b7922f9e3d3ea0b9

@vs-mobiletools-engineering-service2
Copy link
Collaborator

📋 [PR Build] API Diff 📋

API diff (for current PR)

ℹ️ API Diff (from PR only) (please review changes)

API diff: vsdrops gist

Xamarin
.NET
Xamarin vs .NET
iOS vs Mac Catalyst (.NET)

API diff (vs stable)

✅ API Diff from stable

API diff: vsdrops gist

Xamarin
.NET
Xamarin vs .NET
iOS vs Mac Catalyst (.NET)

Generator diff

Generator Diff (no change)

Pipeline on Agent XAMBOT-1100.Monterey'
Hash: 0b89a17580fa2c08c28be477b7922f9e3d3ea0b9

@chamons chamons merged commit 7e8bd5c into xamarin:main May 23, 2022
@chamons chamons deleted the nnyeah_error_refactor branch May 23, 2022 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-notes-worthy Ignore for release notes skip-all-tests Skip all the tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants