Replies: 5 comments 1 reply
-
I incline to "3" because |
Beta Was this translation helpful? Give feedback.
-
I think we want to avoid crashing over layout concerns where possible.
If its a crash error to be in this state then user only finds out when resizing
application really small, or running on a supet small terminal resolution
(e.g. embedded device or something).
I think that like css it should 'do its best' and document the fallback
logics (i.e. min is not respected when parent bounds are less than)
…On Tue, 13 Feb 2024, 18:53 Tig, ***@***.***> wrote:
With Dim.Auto (#3062 <#3062>)
we'll have the ability for a dimension to be specified as "auto, but never
smaller than 'min'": view.Width = Dim.Auto (min: 10).
It is possible for the super view's bounds to be less than 10.
What should we do when we detect this?
1. Throw an exception throw new InvalidOperationException ($"DimAuto
specifies a min size ({autoMin}), but the SuperView's bounds are smaller
({superviewSize}).");.
2. Log a Debug spew message
3. Do nothing and let the app misbehave
I incline to "fail fast" with an exception.
—
Reply to this email directly, view it on GitHub
<#3247>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHO3C5CVDMUIC4ITVP7YYF3YTOZDZAVCNFSM6AAAAABDHASFLWVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZWGIYTIOBQGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
It's entirely situational, honestly. But the guidelines for handling exceptions are relatively deterministic. In general, if an exception is thrown and:
|
Beta Was this translation helpful? Give feedback.
-
Specifically, for the case you presented in the OP, that seems like an appropriate place to throw an InvalidOperationException or something derived from it, if you want to be able to convey more detail to the consumer. Best to put the actual data points in the exception itself and then make the message a localizable string that can substitute those values as appropriate, in the ideal case. As for how that behaves: That's up to the consumer, just like any exception thrown by any dependency of their code. So long as we handle and re-throw appropriately up the stack, we're performing our due diligence. We should try to avoid doing things that obfuscate details like that, because it restricts what the user can do and their visibility into how their program is executing. |
Beta Was this translation helpful? Give feedback.
-
I'd also argue that, any time we throw our own exceptions as the first chance exception, we should include a logging hook at that point, as well. |
Beta Was this translation helpful? Give feedback.
-
With
Dim.Auto
(#3062) we'll have the ability for a dimension to be specified as "auto, but never smaller than 'min'":view.Width = Dim.Auto (min: 10)
.It is possible for the super view's bounds to be less than 10.
What should we do when we detect this?
throw new InvalidOperationException ($"DimAuto specifies a min size ({autoMin}), but the SuperView's bounds are smaller ({superviewSize}).");
.I incline to "fail fast" with an exception.
Beta Was this translation helpful? Give feedback.
All reactions