You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.
I think this API would be easier to use if it either truncated the values to give a value closer to what the user probably wanted or threw an IllegalArgumentException. Here are two possible ways to change the behavior:
If it is important to avoid throwing exceptions, we could truncate the seconds and nanos to their minimum and maximum values. We could throw an IllegalArgumentException if the signs of the seconds and nanos are inconsistent, since it would be unclear what sign the user wanted.
We could throw an IllegalArgumentException if the seconds or nanos are out of bounds or have inconsistent sign. This is more consistent with other parts of the API that enforce all class invariants with checkArgument(...).
The text was updated successfully, but these errors were encountered:
…arguments.
Fixescensus-instrumentation#1179. Throwing IllegalArgumentException for invalid arguments is more
consistent with the rest of the opencensus-java API.
sebright
added a commit
to sebright/opencensus-java
that referenced
this issue
May 15, 2018
…arguments.
Fixescensus-instrumentation#1179. Throwing IllegalArgumentException for invalid arguments is more
consistent with the rest of the opencensus-java API.
…arguments.
Fixescensus-instrumentation#1179. Throwing IllegalArgumentException for invalid arguments is more
consistent with the rest of the opencensus-java API.
Duration.create
returns a "zero" value when the arguments are invalid:opencensus-java/api/src/main/java/io/opencensus/common/Duration.java
Lines 54 to 65 in 773c763
I think this API would be easier to use if it either truncated the values to give a value closer to what the user probably wanted or threw an IllegalArgumentException. Here are two possible ways to change the behavior:
If it is important to avoid throwing exceptions, we could truncate the seconds and nanos to their minimum and maximum values. We could throw an IllegalArgumentException if the signs of the seconds and nanos are inconsistent, since it would be unclear what sign the user wanted.
We could throw an IllegalArgumentException if the seconds or nanos are out of bounds or have inconsistent sign. This is more consistent with other parts of the API that enforce all class invariants with
checkArgument(...)
.The text was updated successfully, but these errors were encountered: