Removing fatal error in method transitionDuration #642
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR modifies the
transitionDuration(using:)
method inFloatingPanelController
to return0.0
instead of callingfatalError
when theFloatingPanelController
instance is not found. This change is crucial for several reasons:Avoiding Crashes in Production: Using
fatalError
in production can lead to unexpected crashes, which are detrimental to user experience. It's safer to return a default value like0.0
and handle the scenario gracefully.Improved Stability: By returning
0.0
, the application can continue running, allowing for better stability and user satisfaction. This approach also aligns with the principle of fail-safety, where the system continues operating under error conditions.Real-World Case: In our large-scale project, we encountered a crash at this specific point due to the
fatalError
. Given the size and complexity of our application, it has been challenging to pinpoint the exact cause. Switching to a return value of0.0
would significantly help us mitigate the issue and maintain app stability while we investigate further.Maintainability: Returning a default value makes the codebase more maintainable and easier to debug, as it avoids abrupt termination and allows for logging or other error handling mechanisms.
Code Changes
We believe this change will benefit not only our project but also others who might face similar issues. Your consideration and review are greatly appreciated.