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

Fix: Handle format exception raised by Convert.ToInt32 #13749

Merged
merged 3 commits into from Nov 8, 2023

Conversation

dragoni7
Copy link
Contributor

@dragoni7 dragoni7 commented Nov 8, 2023

Resolved / Related Issues

Validation
How did you test these changes?

  • Did you build the app and test your changes?
  • Did you check for accessibility? You can use Accessibility Insights for this.
  • Did you remove any strings from the en-us resource file?
    • Did you search the solution to see if the string is still being used?
  • Did you implement any design changes to an existing feature?
    • Was this change approved?
  • Are there any other steps that were used to validate these changes?
    1. Tested code snippet in external test project to ensure System.FormatException was handled

Screenshots (optional)
Add screenshots here.

@yaira2 yaira2 changed the title Handle format exception raised by Convert.ToInt32 Fix: Handle format exception raised by Convert.ToInt32 Nov 8, 2023
@gave92
Copy link
Member

gave92 commented Nov 8, 2023

Hi @dragoni7 thanks for this PR! Please see https://github.com/dragoni7/Files/pull/1/files for suggested changes.

  • Backup conversion should not be needed because Convert.ToInt32() calls int.Parse(string) internally.
  • The exception you're trying to solve is from this line { "FormatDuration", input => TimeSpanToString(new TimeSpan(Convert.ToInt64(input)))}, (note the "ToInt64()" like in the stacktrace) so a try catch is also needed around DisplayFunction.Invoke()

@gave92 gave92 self-requested a review November 8, 2023 20:05
@yaira2 yaira2 merged commit f4ab096 into files-community:main Nov 8, 2023
1 check passed
@yaira2
Copy link
Member

yaira2 commented Nov 9, 2023

@dragoni7 thank you for contributing to Files!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants